Commit Graph

315 Commits

Author SHA1 Message Date
paulhu
e3fe4d0188 Move ACTION_CLEAR_DNS_CACHE to ConnectivityManager
- As API review feedback, move ACTION_CLEAR_DNS_CACHE form Intent
  to ConnectivityManager.

- Rename to "android.net.action.CLEAR_DNS_CACHE" because of lint
  suggestion.
frameworks/base/packages/Connectivity/framework/src/android/net/
ConnectivityManager.java:449: error: Inconsistent action value;
expected `android.net.action.CLEAR_DNS_CACHE`, was
`android.intent.action.CLEAR_DNS_CACHE` [ActionValue]

Bug: 183937999
Test: atest FrameworksNetTests
Test: atest ActivityTaskManagerServiceTests
Test: atest android.permission2.cts.PermissionPolicyTest
Test: atest CtsNetTestCases
Change-Id: Iae8aa0ba10dfc7581f0cfaab82643edbee789e2f
2021-04-07 19:40:47 +08:00
Treehugger Robot
9bc214cd77 Merge "Expose constants of ConnectivityManager" 2021-04-07 10:11:06 +00:00
lucaslin
e8b3f9ced9 Expose constants of ConnectivityManager
The callers cannot call the hidden APIs after ConnectivityManager
became a part of mainline module, so expose them for callers.
Also change the value of ACTION_PROMPT_PARTIAL_CONNECTIVITY,
ACTION_PROMPT_LOST_VALIDATION and ACTION_PROMPT_UNVALIDATED because
of API lint errors.

Bug: 172183305
Test: Check private DNS settings is normal, and test NO_INTERNET
      notification can be shown normally.
Change-Id: I715c766ad8e5eb54f4dc67239c1dbca7239506fc
Merged-In: I715c766ad8e5eb54f4dc67239c1dbca7239506fc
2021-04-07 09:13:46 +00:00
Chiachang Wang
ddfbb93dad Merge "Assign the bit calculation as long to prevent overflow" 2021-04-07 04:24:46 +00:00
Aaron Huang
cbf4cd0487 Remove Network, NetworkRequest metrics from jobscheduler
These metrics are deprecated so remove them from jobscheduler.
Also remove dumpDebug method from Network, NetworkRequest and
NetworkCapabilities because there's no caller anymore.

This change also for connectivity mainline module. These
three classes are inculded in framework-connectivity so
external module cannot have dependencies on its hidden API.
With this change, the dependencies can be removed.

(cherry-picked from ag/13959431)
Bug: 178777253
Test: FrameworksNetTests
      JobStoreTest
      adb shell dumpsys jobscheduler --proto
      CtsIncidentHostTestCases:JobSchedulerIncidentTest
Merged-In: Ie0c540303ba06b8fba029d2b98ae753afb08c963
Change-Id: Ie0c540303ba06b8fba029d2b98ae753afb08c963
2021-04-07 12:22:57 +08:00
Chiachang Wang
9024d7849e Assign the bit calculation as long to prevent overflow
The value should be assigned as a long to do the bit calculation
as the mNetworkCapabilities is intended to be a long. Otherwise,
the value will be temporary assigned into an integer then
assigned to the target long. When the bit shift calculation
is out of the integer scope, the calculation will overflow and
result in unexpected bebavior.

Without assigning to a long, ConnectivityServiceTest will get
Out-Of-Memory in StringBuilder while generating toString() in
NetworkCapabilities after updating tests to verify
NET_CAPABILITY_VSIM and NET_CAPABILITY_BIP.

Bug: 130869457
Test: atest FrameworksNetTests
Change-Id: I4d34c1215c7efb6dc352c314107792e3fa512ad7
2021-04-07 02:06:33 +00:00
Treehugger Robot
caae5a26a6 Merge "ConnectivityManager: Address review comments from aosp/1595396" 2021-04-07 00:36:27 +00:00
Roshan Pius
e12202665f ConnectivityManager: Address review comments from aosp/1595396
Bug: 156867433
Test: atest android.net
Test: atest com.android.server
Change-Id: I7f5d043732ae22edd14bf581b7dc676c9236b545
2021-04-06 16:42:51 +00:00
Roshan Pius
98f68a245b Merge "NetworkCapabilities: Hide copy constructor" 2021-04-06 15:57:47 +00:00
Frank Li
d47c7d9765 Merge "Add session ID to VpnTransportInfo" 2021-04-06 06:50:48 +00:00
Ken Chen
601140eef7 Merge "Downgrade DNS fail message from Error to Warning" 2021-04-06 06:35:04 +00:00
Chalard Jean
c32e1c90d6 Merge "Cleanup setGlobalProxy" 2021-04-06 06:19:01 +00:00
James Mattis
62b38c4edb Adding OEM Network Preferences for testing
Added two new per-app OEM network preferences to be used only with
testing.

Although there is a tradeoff adding these preferences to
non-test code, the benefit is that it will allow testing of the OEM
network preferences app via CTS as using the shell with elevated
permissions is not an option due to the OEM network preferences API
potentially being abused. On consideration, a small amount of test code
was deemed an acceptable tradeoff if it enabled CTS testing.

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

Change-Id: Ie896a7b40945a46a352f37d2c00671da8a8f4489
2021-04-05 21:51:09 -07:00
Ken Chen
f6f3930a5b Downgrade DNS fail message from Error to Warning
Most DNS fails are caused by network issues, like connection timed out.
Lower log severity from error to warning to conform to go/greenlog.

Test: 1. connect to a WiFi AP without WAN
      2. atest CtsNetTestCases:android.net.cts.DnsResolverTest
      3. adb logcat | grep resNetworkResult:android
Bug: 181269159
Change-Id: Ifeaf250c91a4b9123d200bd62f085c11009f2491
2021-04-06 02:30:56 +00:00
Steven Moreland
f672458e88 Merge "Remove unstable IpPrefix" 2021-04-05 21:59:47 +00:00
Roshan Pius
528ed9d9a4 NetworkCapabilities: Hide copy constructor
Only used by connectivity service, no need to mark it public.

Bug: 184537591
Test: Compiles
Change-Id: Ie0d515d73e30a4e15141a3d92aa739192badeb13
2021-04-05 09:29:30 -07:00
Benedict Wong
ef8df21168 Merge "Downgrade list of subIds in NetworkCapabilities to @SystemApi" 2021-04-02 22:33:20 +00:00
Sarah Chin
7457cb0cf8 Merge "API to get network visible network capability name" 2021-04-02 16:50:10 +00:00
Chalard Jean
48d60ea9e3 Cleanup setGlobalProxy
This is a small cleanup of a function called by DevicePolicyManager
coming from a conflicting change. This no longer makes a concrete
difference but is still a good change.

Test: m services.devicepolicy
Bug: 172183305
Change-Id: I7ee907314ddb253eb4e97d177f0ea0ab3b58cf03
2021-04-02 20:37:21 +09:00
Benedict Wong
53de25fe46 Downgrade list of subIds in NetworkCapabilities to @SystemApi
This change downgrades API visibility for the list-of-subIds in the
NetworkCapabilities to SystemApi

Bug: 175662146
Test: atest NetworkCapabilitiesTest#testSubIds
Test: atest FrameworksNetTests
Change-Id: I372fa9eaa7585aefd1710948ca007456feedd578
2021-04-02 01:18:11 -07:00
Steven Moreland
c6a80bbb16 Remove unstable IpPrefix
Seems nothing is using this.

Bug: 183654927
Test: N/A
Change-Id: I94233d79fb5d93970b38a79a09fc4d50822c3620
2021-04-01 22:59:02 +00:00
Aaron Huang
5d837faebe Merge "Expose BIP and VSIM relavent definitions" 2021-04-01 11:38:17 +00:00
Aaron Huang
9489cff024 Merge "Move deduceRestrictedCapability to libs/net and rename it" 2021-04-01 11:37:51 +00:00
lifr
dbee04c122 Add session ID to VpnTransportInfo
- This will be visible only to apps with the NETWORK_SETTINGS
  permissions (signature), and will be redacted for all other callers.
- This string is expected to be the same as set by
  VpnService#setSession, and in general, VpnConfig.session. But it
  will be a general API that Vpn.java can call when setting the
  VpnTransportInfo.
- This string cannot be updated once the VPN NetworkAgent is connected.

Bug: 171872481
Test: atest ConnectivityServiceTest
      atest VpnTransportInfoTest
      atest android.net.cts.NetworkAgentTest
Change-Id: I8d09e25b83f7ee8be21ec9c9bd3c72a251f1370d
Merged-In: I8d09e25b83f7ee8be21ec9c9bd3c72a251f1370d
           (cherry-picked from ag/14011912)
2021-04-01 15:46:31 +08:00
Frank Li
fb291179cf Merge "[JS01]Remove hidden API usage of Connectivity Sevice" 2021-03-30 07:22:40 +00:00
lifr
42a60c2ebc [JS01]Remove hidden API usage of Connectivity Sevice
The Connectivity service will become the mainline module.
Therefore, remove the caller of using Connectivity's
hidden API outside the module and expose the required
connectivity API used in Jobscheduler.

Bug: 183456204
CTS-Coverage-Bug: 170598012
Test: atest JobStoreTest
Change-Id: Ie6bc81ff382fb242b98f35d28a96defc207c7987
Merged-In: Ie6bc81ff382fb242b98f35d28a96defc207c7987
           (cherry-picked from ag/13946348)
2021-03-30 11:41:50 +08:00
Lorenzo Colitti
d5385c4537 Add a setTeardownDelayMs API to NetworkAgent.
This allows transports to request that when the network is
disconnected, the system should delay destroying the native
network until the specified time has passed after the network
disconnected.

Bug: 181941583
Test: next CL in the stack
Change-Id: I9765f1c9d1e55c23c6d583d6709dbe06505975b1
2021-03-29 21:33:08 +09:00
Lorenzo Colitti
42fe223f70 Address comments on onBlockedStatusChanged(Network, int) CL.
Test: m
Bug: 165835257
Change-Id: I6d3007a1eac54ee6650b350aee56ed398a2c950d
2021-03-29 20:12:09 +09:00
lifr
75764c8666 [TL02]Remove hidden API usage of NetworkAgent
The connection service will become the mainline module.
Remove the hidden API usage of NetworkAgent.

Bug: 170598012
CTS-Coverage-Bug: 170598012
Test: atest FrameworksNetTests FrameworksTelephonyTests
      atest FrameworksWifiTests
Change-Id: I4e4040ae7f94bdf479c7df9ec2ffabafbe06331c
Merged-In: I4e4040ae7f94bdf479c7df9ec2ffabafbe06331c
2021-03-29 15:33:44 +08:00
Remi NGUYEN VAN
a98ed4b5df Merge "Re-implement NetworkUtils#queryUserAccess." 2021-03-29 04:57:40 +00:00
Lorenzo Colitti
22c677e086 Re-implement NetworkUtils#queryUserAccess.
Currently, queryUserAccess talks to netd via FwmarkServer.
Doing this from the module would require exposing queryUserAccess
as an NDK API or reimplementing FwmarkClient.

Because queryUserAccess really only uses information that comes
from ConnectivityService/PermissionMonitor anyway, just use that
information without calling to net.

Test: atest HostsideVpnTests
Bug: 171540887
Merged-In: If855de1ea3e1fd2ed30f2795d9b4acfcf969a2dc

Change-Id: If855de1ea3e1fd2ed30f2795d9b4acfcf969a2dc
2021-03-29 12:11:19 +09:00
Chiachang Wang
cbb5e0e908 Expose BIP and VSIM relavent definitions
In order to support special APNs below, OEM may need extra
NetworkCapabilities and apn type definition to support the
carriers request. Add corresponding definition into API
surface.

VSIM: for Virtual SIM service
BIP: for Bearer Independent Protocol

Bug: 130869457
Test: make update-api
Change-Id: I41e881c6fe39e92d5cdac2d0a02fa8a8e814c9c5
Merged-In: I41e881c6fe39e92d5cdac2d0a02fa8a8e814c9c5
2021-03-26 06:17:25 +00:00
Aaron Huang
522918f4ba Move deduceRestrictedCapability to libs/net and rename it
NetworkCapabilities is included in framework-connectivity, so external
module cannot have dependencies on its hidden API. Move the method to
libs/net so that external modules can use it by including the library.

Bug: 178777253
Test: FrameworksNetTests
(cherry-picked from ag/13921626)
Merged-In: I77970b3a5e5e0e9d263639694b1f06519169bf64
Change-Id: I77970b3a5e5e0e9d263639694b1f06519169bf64
2021-03-26 14:13:51 +08:00
Treehugger Robot
a5ba719999 Merge "Add network disconnected callback" 2021-03-26 05:47:33 +00:00
Chiachang Wang
a9ffc14b41 Add network disconnected callback
Create a network callback to notify network agent after the
native network being destroyed by netd which means the network
is fully disconnected. The NetworkAgent may handle this event
after sending disconnect state to ConnectivityService to proceed
its pending works that have to be done after it.

Bug: 178725261
Test: make update-api
Change-Id: I602ff2c688909473b03b72c9407d4286608cff4c
Merged-In: I602ff2c688909473b03b72c9407d4286608cff4c
2021-03-26 02:53:29 +00:00
Sarah Chin
d9e35a3f1b API to get network visible network capability name
Test: atest DataConnectionTest, DcTrackerTest
Bug: 181916712
CTS-Coverage-Bug: 183553812
Change-Id: Iae63ac4d62641cee2bd0f0c5f50dd729750d514c
Merged-In: Iae63ac4d62641cee2bd0f0c5f50dd729750d514c
2021-03-25 15:10:39 -07:00
Lorenzo Colitti
79c6f228a6 Add onBlockedStatusChanged(Network, int) to NetworkCallback.
This is similar to onBlockedStatusChanged(Network, boolean) but
it allows the callback holder to know the exact reason why
networking was blocked. It is useful to privileged system
components such as JobScheduler that are able to ignore some
blocked reasons but not others.

Also add a new BLOCKED_REASON_LOCKDOWN_VPN that is used when
networking is blocked because an always-on VPN is in
lockdown mode.

Also move BLOCKED_METERED_REASON_MASK to ConnectivityManager.
This is necessary because ConnectivityService must ensure that
the blocked status callbacks are correctly sent when meteredness
changes (e.g., a UID that is blocked on metered networks will
become unblocked on a network that becomes unmetered). In order
to do this it needs to know which reasons apply only on metered
networks.

Bug: 165835257
Test: unit tests in subsequent CLs in the stack
Change-Id: I647db4f5a01280be220288e73ffa85c15bec9370
2021-03-26 02:37:19 +09:00
paulhu
5082bf7ba3 Add MOBILE_DATA_PREFERRED_APPS setting
This setting is OEM upstream requirement for mobile data
preferred apps feature.

Bug: 171872461
Test: atest FrameworksNetTests
Merged-In: Ic5e0515b2b948de3d333c8d8e073d0b15514562a
Change-Id: Iba17bf68cffbe39d1c08ad94364b41bbf851bf57
2021-03-26 02:37:19 +09:00
paulhu
89a762a82c Add PRIVATE_DNS_MODE setting setter
Bug: 182538166
Test: atest FrameworksNetTests
Merged-In: If234426f041606c4881de1eca31b6f5bdb3c6bfe
Change-Id: Iaa9e6cc92f1805ab341c308fc60e947ec4c674f0
2021-03-26 02:37:16 +09:00
paulhu
58d9a35f4d Expose ConnectivitySettingsManager as module-lib API
Have getter/setter methods for external modules that can
get/set the setting values.

Bug: 182538166
Test: atest FrameworksNetTests
Merged-In: I82225a43f95e3e1d3e52c4e7a0fc541c0087292e
Change-Id: I61cb00216494e35b6e0dfe444b177cad36ad8afb
2021-03-26 02:35:07 +09:00
Chiachang Wang
33f5f36c68 Merge "Add network created callback support" 2021-03-25 13:22:17 +00:00
Lucas Lin
62370d9e84 Merge "Expose some APIs from ConnectivityManager" 2021-03-25 11:29:08 +00:00
Lucas Lin
ed9e903a5e Merge changes Ic2357dcf,Iddf8c71a
* changes:
  Expose NetworkAgent constructor taking a NetworkScore parameter
  Expose NetworkScore to external caller
2021-03-25 11:28:28 +00:00
Chiachang Wang
3f6cc0758f Add network created callback support
Create a network callback to notify network agent after
netd has created the network, so that the NetworkAgent may
wait for this callback and ensure the pre-work to communicate
with netd completed.

Bug: 178725261
Test: make update-api
Change-Id: I8c2ff7bd6980ae838abc5669f9419d62741b8666
Merged-In: I8c2ff7bd6980ae838abc5669f9419d62741b8666
2021-03-25 18:27:24 +08:00
Chiachang Wang
2ae2d158e5 Expose NetworkAgent constructor taking a NetworkScore parameter
Vpn constructs NetworkAgent with this exposed NetworkAgent
constructor. Given NetworkAgent is moving into the incoming
connectivity module, Vpn which is outside the module will not
be able to access it if it's not in the API surface. Thus,
expose it to allow Vpn to use it.

Bug: 182963397
Test: make update-api
Change-Id: Ic2357dcfff3233e0dd17b48b0e376a5095ef60fa
Merged-In: Ic2357dcfff3233e0dd17b48b0e376a5095ef60fa
CTS-Coverage-Bug: 172183305
  (cherry-picked from ag/13966707)
2021-03-25 08:40:27 +00:00
lucaslin
9a2ee9e590 Expose NetworkScore to external caller
NetworkScore will be a part of mainline module, so the external
callers cannot call its hidden APIs. Expose needed APIs to
the external callers.

CTS-Coverage-Bug: 182963397
Bug: 182963397
Test: m
Change-Id: Iddf8c71a5f51a40bc6ff78626b3e8ee530d1b7eb
Merged-In: Iddf8c71a5f51a40bc6ff78626b3e8ee530d1b7eb
  (cherry-picked from ag/13947595)
2021-03-25 08:15:09 +00:00
lucaslin
e257bcea8f Expose some APIs from ConnectivityManager
- Expose setRequireVpnForUids to Vpn.java
- Expose setLegacyLockdownVpnEnabled to LockdownVpnTracker.java
- Expose requestRouteToHostAddress to
  GnssNetworkConnectivityHandler.java

Bug: 182963397
Test: m
Change-Id: I1fb5ecfbe37878ba3534e6c6c7599ca29db2735c
Merged-In: I1fb5ecfbe37878ba3534e6c6c7599ca29db2735c
  (cherry-picked from ag/13927657)
2021-03-25 08:07:53 +00:00
Jayachandran Chinnakkannu
4f51028891 Merge "Add 5G/NR QOS support" 2021-03-24 17:44:48 +00:00
Sudheer Shanka
982155658d Move BLOCKED_REASON_* constants from NPMS into ConnectivityManager.
These constants will now be including all the reasons for why an
uid's network access can be blocked, instead of only the
restrictions that could be imposed by NPMS.

Bug: 183473548
Test: atest ./tests/cts/hostside/src/com/android/cts/net/HostsideRestrictBackgroundNetworkTests.java
Merged-In: I4c544415e12adf442fd2415c371b1b70a39c3aa4
Change-Id: I6dcea43fbefa9eac8b5a971b822a5be5422a54b4
2021-03-25 01:33:26 +09:00
Jayachandran C
6cdedaee91 Add 5G/NR QOS support
Bug: 155176305
Bug: 182317794
Test: atest ConnectivityServiceTest
      atest QosCallbackTrackerTest

Change-Id: Idf6d8a7c3b80bc50a2c1244ceaefea9381d40c2f
2021-03-23 19:14:21 -07:00