Commit Graph

159 Commits

Author SHA1 Message Date
Anthony Stange
43b606da89 Revert "Expose uids related APIs in NetworkRequest and NetworkCa..."
Revert "Add shims for NetworkRequest"

Revert submission 1626206-replaceUidRange

Reason for revert: Breaking build - b/183106405
Reverted Changes:
I0b79c73e8:Add shims for NetworkRequest
I4bc0daf5a:Replace the usage of UidRange
I4e5aec6ef:Replace the usage of UidRange
I107c329d4:Expose uids related APIs in NetworkRequest and Net...

Change-Id: I45e08f89533af0d6851add38fecb5c6c114615ae
2021-03-18 16:30:59 +00:00
Chiachang Wang
347208541a Expose uids related APIs in NetworkRequest and NetworkCapabilities
NetworkRequest is moving into the incoming connectivity mainline
module. The hidden setUids becomes inaccessible outside the
module. Shims for support cts in different API levels will need
to use it to verify the behavior of NetworkRequest. Thus, expose
it to the API surface.

Also, VPN uses getUids and setUids to control network
capabilities. Networkcapabilities is a part of incoming
connectivity mainline module but VPN is not. Thus, exposing these
two methods are needed to allow VPN to continue using it.

Test: make update-api
Bug: 172183305
Change-Id: I107c329d4d7130d488772166eae8b5e7aaa2ff04
2021-03-17 23:13:39 +08:00
Chiachang Wang
0843e480ca Replace the usage of UidRange
UidRange is used in a shared way between ConnectivityService
and VPN through the use of NetworkCapabilities. UidRange will
be part of the ConnectivityService mainline but Vpn.java will
stay in the framework. We need a way to replace the APIs using
UidRange, or to make UidRange system API. The only really
relevant surface here is NetworkCapabilities#{setUids, getUids}.
The need for UidRange could be replaced by an integer Range, so
replace the usage of UidRange by a integer Range in
NetworkCapabilities#{setUids, getUids} and update the relevant
callers.

Bug: 172183305
Test: atest FrameworksNetTests CtsNetTestCasesLatestSdk
Change-Id: I4e5aec6ef1ea02e038fcd7ed117a3b67b69c5cb9
2021-03-17 23:02:22 +08:00
Remi NGUYEN VAN
a902c7cc88 Merge "Remove extra comment" 2021-03-17 12:16:09 +00:00
Remi NGUYEN VAN
0d4c38d9c4 Remove extra comment
This fixes a merge conflict with downstream branches due to an
incomplete cherry-pick.

Bug: 171540887
Test: m

Change-Id: I27a8f20f1a1d83b472700648f3f5a68413a76ac3
Merged-In: I7432fe4c87cd3cab04dcb6185c9a4f3f84376549
2021-03-17 10:58:08 +00:00
lucaslin
7abe7e01a9 Modify the comment of getPrivateDnsMode
Bug: 172183305
Test: m
Change-Id: I2f1b44cf2a362b42f052ea5d34a5cec03d46e661
2021-03-17 14:53:35 +08:00
Lucas Lin
60b3e230b6 Merge "Change the parameter type from ContentResolver to Context" 2021-03-17 06:35:21 +00:00
Chalard Jean
85538adb19 Merge changes I335e82e2,I84ba363d,I8f18083b,I854a952d,I00e23441
* changes:
  Remove per-user preference when the user is removed
  Expose the enterprise per-profile networking API.
  Implement setNetworkPreferenceForUser.
  Public API for per-profile network preference.
  Add tests for setNetworkPreferenceForUser
2021-03-17 05:48:18 +00:00
Remi NGUYEN VAN
032cd3914a Merge "Remove MessageUtils usage in VpnTransportInfo" 2021-03-17 00:14:10 +00:00
junyulai
8eb13a2b3d [VCN14] Expose registerBestMatchingNetworkCallback
Test: m -j doc-comment-check-docs
Bug: 175662146
Change-Id: Ie67dd2f4f8d973de37bc64a03908d7cbb7c2b7ad
2021-03-16 21:30:56 +08:00
junyulai
1b1c874db4 [VCN13] Implement tracking best matching network
This is done by:
  1. In requestNetwork, provide a basic permission check.
  2. rematchNetworksAndRequests: no change, since non listen
     requests will be automatically processed to track
     best satisfying network.
  3. applyNetworkReassignment: no change, since non-request
     will not be sent to factories.

Test: atest ConnectivityServiceTest#testRegisterBestMatchingNetworkCallback_noIssueToFactory
Test: atest ConnectivityServiceTest#testRegisterBestMatchingNetworkCallback_trackBestNetwork
Bug: 175662146
Change-Id: I8cf4ab334df6812d84cdda160e9b72b6f54062af
2021-03-16 21:30:55 +08:00
Paul Hu
01a8210f33 Merge "Replace interal okhttp APIs" 2021-03-16 12:18:49 +00:00
Chalard Jean
6010c00ecd Expose the enterprise per-profile networking API.
Also unify the listener for Oem settings, which have
never been released as public API (it is slated to be
released in S).

Test: FrameworksNetTests
Change-Id: I84ba363dd0ec03871c37b1c3a31e5557d9aa12e7
2021-03-16 12:14:00 +00:00
Chalard Jean
b5a139f32a Implement setNetworkPreferenceForUser.
Test: FrameworksNetTests
Change-Id: I8f18083b5857289892fe8adea5f5ea3f5dbe0809
2021-03-16 12:13:46 +00:00
Chalard Jean
fa45a68c91 Public API for per-profile network preference.
This patch defines the API, but does not make it public
yet as there is no implementation yet.

Test: none so far
Change-Id: I854a952dfe35cc80847eb62f522b1667b8e9b8a0
2021-03-16 12:13:27 +00:00
lucaslin
20f0488017 Change the parameter type from ContentResolver to Context
Context is more useful than ContentResolver, it can provide more
information if we want to change the behavior in the future.

Bug: 172183305
Test: atest FrameworksNetTests
Change-Id: I5702c7d74b862a76558b94f1abe2c6df9eb7f097
Merged-In: I5702c7d74b862a76558b94f1abe2c6df9eb7f097
2021-03-16 09:26:57 +00:00
Lucas Lin
de22605a9a Merge "Add comments to describe the value of converting hex to decimal" 2021-03-16 08:31:10 +00:00
Lucas Lin
6228e2c6c8 Merge "Have a new API to get private DNS mode" 2021-03-16 07:39:35 +00:00
Chalard Jean
0e6446cc22 Merge "[NS01] Add NetworkScore" 2021-03-16 06:36:07 +00:00
Remi NGUYEN VAN
32aa7de40d Merge "Add ParseException constructors to API" 2021-03-16 06:25:16 +00:00
paulhu
405d8911e9 Replace interal okhttp APIs
Connectivity is becoming a mainline module in S but mainline
modules are not allowed to use non-formal APIs. Thus, replace
internal okhttp APIs to stable libcore APIs which are created for
using HttpURLConnectionFactory.

Bug: 182238821
Test: atest FrameworksNetTests
Change-Id: I56ba1b9e6e94f9c6519c3f1c8f0c5993fccbe185
2021-03-15 23:06:15 +08:00
Aaron Huang
c8e73fa90b Merge changes from topic "pacproxy-service"
* changes:
  Make PacProxyService be a system service
  Revert^2 "Refactor setCurrentProxyScriptUrl to a void method"
2021-03-15 11:49:45 +00:00
lucaslin
0cdcea187a Add comments to describe the value of converting hex to decimal
Bug: 172183305
Test: N/A
Change-Id: Id274295d6c8c97d3014214f875168ff968f79bb6
2021-03-15 09:55:39 +00:00
Chalard Jean
2801857fec [NS01] Add NetworkScore
As attested by numerous TODOs in the code, a new way of
representing network quality and policy is needed instead
of an int.

An int representing the quality of the network requires
all parties using it to know how all other parties are
using it, and implementation details about the decision
algorithm. For all intents and purposes, the selection
is left to individual network factories who try to
achieve a desired result while piecing together all
possible states of the system.

As the number of such cases and desires increases, this
becomes both intractable and unmaintainable. Indeed, at
this time in the codebase nobody can really predict exactly
how a given change in score will affect selection across
the board, and it is essentially impossible to figure out
the behavior of network selection by inspecting the code
because the moving parts are scattered throughout the
entire codebase.

Having an object encapsulating policy and quality values
will let us centralize the selection and make it again
possible to maintain without knowledge of all behaviors
of all network factories. It will also provide better
guarantees of respecting policy, and allow bugfixes that
were not possible before because they'd touch too many
parts of the code.

Test: FrameworksNetTests FrameworksWifiTests NetworkStackTests
Change-Id: I3185a6412b9b659798faf0c6882699e9c63cc115
2021-03-15 09:49:47 +00:00
Remi NGUYEN VAN
ff9ae37eb9 Merge "Revert "Remove connectivity dependency on Preconditions"" 2021-03-15 07:30:20 +00:00
Remi NGUYEN VAN
5086c29568 Revert "Remove connectivity dependency on Preconditions"
This reverts commit 62b1df44a2.

Reason for revert: Build broken: b/182721112

Change-Id: Ibc84ec6d7900fdcf0bc14cd7036f9c08287711db
2021-03-15 07:27:44 +00:00
Paul Hu
05c16014dc Merge "Replace InetAddress#parseNumericAddress" 2021-03-15 07:03:46 +00:00
Aaron Huang
f9fa0b95a8 Make PacProxyService be a system service
PacProxyInstaller class is running a thread all the time and is
listening to intent ACTION_PAC_REFRESH so it would be better to
make it be a system service with a manager class PacProxyManager
which is obtained with getSystemService(PacProxyManager.class).
Besides, rename PacProxyInstaller to PacProxyService will
be easier to know it's the service for PacProxyManager.

ConnectivityService is going to be a mainline module and it
needs constructor of PacProxyService to be SystemApi.
However, in current design, it needs to pass a handler and
an int arguments to the constructor which would be difficult
to maintain if just expose the constructor directly.

So, define a listener for the event that the current PAC
proxy has been installed so that the handler and the int
arguments can be removed from the constructor.

Bug: 177035719
Test: FrameworksNetTests
Change-Id: I2abff75ec59a17628ef006aad348c53fadbed076
2021-03-15 14:40:58 +08:00
Remi NGUYEN VAN
e59a0c2ff6 Merge "Remove connectivity dependency on Preconditions" 2021-03-15 06:36:15 +00:00
Remi NGUYEN VAN
e87d4bca6a Merge "Remove VpnType usage in VpnTransportInfo" 2021-03-15 01:52:30 +00:00
Remi NGUYEN VAN
94e5fff53d Add ParseException constructors to API
ParseException constructors are used by both platform and mainline
module code, so they can't be package-private.
Removing dependencies on either side is not possible as the class
itself is part of the public API, and supports APIs on both sides.

Having the constructors part of the API makes the class usable by both
sides.

Fixes: 182705505
Test: CtsNetTestCases for APIs using the exception
Change-Id: Ia396ab2fa3afaed3cf474c8e60f72fc7f3f4fded
2021-03-15 10:26:02 +09:00
Remi NGUYEN VAN
e642d483a4 Remove MessageUtils usage in VpnTransportInfo
MessageUtils is a hidden utility, and including a jarjared copy in
framework-connectivity would add complexity.
It is only used in VpnTransportInfo, where it would parse VPN constants
when the class is loaded in each process. Considering the performance
and maintenance cost using numerical type codes in toString() seems to
be a better tradeoff.

Bug: 177046265
Test: m
Change-Id: Ie71cc816f86e020b44ed1c86349b5c9204dee3cf
2021-03-14 15:45:14 +09:00
paulhu
1013c81acb Replace InetAddress#parseNumericAddress
-Connectivity is becoming a mainline module in S but mainline
modules are not allowed to use non-formal APIs. Thus, replace
non-formal API InetAddress#parseNumericAddress to
InetAddresses#parseNumericAddress.
- Add deprecated method legacyParseIpAndMask() for IpPrefix and
LinkAddress. Because InetAddresses#parseNumericAddress has
a little different behavior in some case, but these two classes
should keep working as before. So these two classes will use
the new deprecated method.

Bug: 181756157
Test: FrameworksNetTests
Change-Id: I1c96b75f0b8d5e93304a39b4a8c8849964e5e810
2021-03-12 19:57:40 +08:00
lucaslin
705c333a1e Have a new API to get private DNS mode
- Expose PRIVATE_DNS_MODE_OFF, PRIVATE_DNS_MODE_OPPORTUNISTIC and
PRIVATE_DNS_MODE_PROVIDER_HOSTNAME for external users.
- Since PRIVATE_DNS_DEFAULT_MODE_FALLBACK might be changed from
release to release, so it cannot be exposed as a system API.
Remove PRIVATE_DNS_DEFAULT_MODE_FALLBACK and have a new API -
getPrivateDnsMode() for users to get the private DNS mode instead.

Bug: 172183305
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I02a1e91b4eafb5f5df3eada1c07b99849a050c3c
Merged-In: I02a1e91b4eafb5f5df3eada1c07b99849a050c3c
2021-03-12 17:56:09 +08:00
Remi NGUYEN VAN
baf1680f8b Remove VpnType usage in VpnTransportInfo
The VpnType annotation is a hidden symbol, and should be
kept hidden as annotations are disallowed by API guidelines.

Remove its usage in VpnTransportInfo as users of annotated constants
that build against API stubs are expected not to use the annotation.

Bug: 173331190
Test: m
Change-Id: I171fa57f6279defad081c3cd16265d58ec55e57d
2021-03-12 18:30:30 +09:00
Remi NGUYEN VAN
7d3fe9570b Merge "Remove usage of hidden InetSocketAddress constructor" 2021-03-12 09:02:15 +00:00
Treehugger Robot
cd6324c135 Merge "Remove hidden @NetworkType in NetworkInfo" 2021-03-12 08:59:35 +00:00
Treehugger Robot
122c15f5d5 Merge "Remove hidden INVALID_RESOURCE_ID in unused param" 2021-03-12 08:57:55 +00:00
Treehugger Robot
f050e5d627 Merge "Use ParcelDescriptor.fromSocket instead of getFileDescriptor" 2021-03-12 08:57:47 +00:00
Junyu Lai
d12480ed60 Merge changes from topics "vcn04", "vcn12"
* changes:
  [VCN12] Expose setSubIds/getSubIds APIs
  [VCN04] Add Subscription Id set into NetworkCapabilities
2021-03-12 07:12:59 +00:00
Roshan Pius
2bead69f56 Merge "ConnectivityManager: Provide API's to include location sensitive info" 2021-03-12 05:56:29 +00:00
Treehugger Robot
64d0760e87 Merge "Remove Slog usage in NetworkState" 2021-03-12 05:12:26 +00:00
Remi NGUYEN VAN
bd372ae3fa Merge "Move ParseException to Connectivity" 2021-03-12 04:27:55 +00:00
Lucas Lin
54307cc3fc Merge changes Ib80f814f,Ic605e489
* changes:
  Use new API - getIpSecNetIdRange() in IpSecService
  Add a new API to get the network ID range of IPSec tunnel interface
2021-03-12 03:30:32 +00:00
Roshan Pius
951c003ef4 ConnectivityManager: Provide API's to include location sensitive info
Existing NetworkCallback users will get NetworkCapabilities with
location sensitive data removed (except for ownerUid which will be
added for existing apps for backwards compatibility). Apps
have to opt-in to receive location sensitive data.

Note: This was chosen because WifiInfo is the only TransportInfo tha
has location sensitive info & that was added only in Android 12. If we
choose to default to true, all existings apps retrieving
NetworkCapabilities for wifi networks will be blamed for location access
unnecessarily.

Changes:
i) Add a flag in NetworkCallback creation to retrieve
NetworkCapabilities with location sensitive info in their callback.
(More flags are being planned for NetworkCallback for throttling
callback frequency, etc)
ii) For NetworkCapabilities.getOwnerUid(), we will continue to send the
data for apps targeting older SDK (since this is an existing field and
the new flag defaults location sensitive data to off).

Bug: 156867433
Test: atest android.net
Test: atest com.android.server
Change-Id: If70b5ea6f5c8885f0c353c8df08a826d55fe7f7a
2021-03-11 18:27:18 -08:00
Remi NGUYEN VAN
b833c6bcbd Merge changes from topic "ethernet_specifier"
* changes:
  Fix common tests on Q and R
  Add Ethernet, TestNetworkSpecifier API
2021-03-11 23:51:49 +00:00
lucaslin
30e70a82c0 Add a new API to get the network ID range of IPSec tunnel interface
- Add a new API to get the network ID range of IPSec tunnel
interface.
- Use the new API in IpSecServiceTest to make sure the result is
the same. Follow-up commit will change the logic in
IpSecService#reserveNetId(), the modified test can ensure the
correctness of the new change.

Bug: 172183305
Test: atest FrameworksNetTests:IpSecServiceTest
Change-Id: Ic605e48941fc9d6482cdcd01a8adcdc9b6d586a6
2021-03-12 00:46:33 +08:00
junyulai
e53fbc08c9 [VCN12] Expose setSubIds/getSubIds APIs
Test: atest NetworkCapabilitiesTest
Bug: 175662146
Change-Id: Ia4b98bc6c5fcefee44233f3b7fbb6517a0e8870e
2021-03-11 23:03:19 +08:00
junyulai
e587a4c39e [VCN04] Add Subscription Id set into NetworkCapabilities
This is a generic way to request networks that has different
subId but belongs to the same carrier. For example, cellular
networks with different SIM card, or carrier Wifi that
provided by the operator.

Test: atest NetworkCapabilitiesTest#testSubIds
Test: m doc-comment-check-docs -j
Test: atest CtsNetTestCases
Bug: 175662146

Change-Id: Ifca766f5acc73c285948d6251ec31506d9bb0bcb
2021-03-11 23:03:05 +08:00
Remi NGUYEN VAN
57c9cc2614 Add Ethernet, TestNetworkSpecifier API
Rename StringNetworkSpecifier to EthernetNetworkSpecifier (its only
production user), and make it module-lib API.
The original StringNetworkSpecifier file is actually kept to satisfy
some invalid dependencies; it will be removed separately.

This allows specifying an Ethernet interface with a non-deprecated API:
until this change the only way to do so would be to use
NetworkRequest#setSpecifier(String), which is deprecated.

Similarly, add the TestNetworkSpecifier API for TestNetworkManager, to
replace previous usage of StringNetworkSpecifier. TestNetworkManager is
module API, so TestNetworkSpecifier should be module API too. This
allows tests to request the test interface specifically, without using
the deprecated NetworkRequest#setSpecifier(String).

Bug: 179329291
Test: m
Merged-In: Iee569f5c8bbdc4bc979610e1191308281f3d4620

Change-Id: Iee569f5c8bbdc4bc979610e1191308281f3d4620
2021-03-11 23:02:02 +08:00