Commit Graph

12567 Commits

Author SHA1 Message Date
Lorenzo Colitti
cbc6a315c5 Merge changes I24580ea4,Id48b8eab
* changes:
  Allow the system to register 250 NetworkCallbacks.
  Add more test coverage for limiting the number of callbacks.
2021-03-30 16:01:58 +00:00
Lorenzo Colitti
b4f8d8e130 Allow the system to register 250 NetworkCallbacks.
Give anyone with PERMISSION_MAINLINE_NETWORK_STACK (i.e.,
either the system or the networkstack process) a separate limit
of 250 callbacks per UID.

Bug: 183921387
Test: new unit tests
Change-Id: I24580ea48e3ad502ef584efc5fde0b5d22e392b4
2021-03-30 22:54:01 +09:00
Lorenzo Colitti
64ef4d3785 Add more test coverage for limiting the number of callbacks.
Bug: 183921387
Test: test-only change
Change-Id: Id48b8eab507fb616cb0adfeba52e00858d44b8a6
2021-03-30 20:28:36 +09:00
Treehugger Robot
364ad64fa7 Merge changes I3826b9ef,I91d68ca3
* changes:
  Add static for constant
  Get NetworkCapabilities from NetworkCallback
2021-03-30 08:22:41 +00:00
Frank Li
0557b8b4c6 Merge "[JS01]Remove hidden API usage of Connectivity Sevice" 2021-03-30 07:22:40 +00:00
lifr
d023f35cc3 [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
2206e976c1 Merge changes If539cf5d,I9765f1c9,I6d3007a1
* changes:
  Add test coverage for NetworkAgent callbacks.
  Add a setTeardownDelayMs API to NetworkAgent.
  Address comments on onBlockedStatusChanged(Network, int) CL.
2021-03-30 00:38:47 +00:00
Sudheer Shanka
90358f5154 Remove NetworkPolicyManager.isUidBlocked() API.
It isn't used by ConnectivityService any more and even if
it needs such utility method in the future, we could create
one which is part of connectivity module and doesn't need
to be exposed as part of NetworkPolicyManager API surface.

Bug: 183696103
Test: atest ./tests/net/java/com/android/server/ConnectivityServiceTest.java
Change-Id: Ie3c681f88e4b2b9bb92d2224c5ea96b074f155d5
2021-03-29 12:39:12 +00:00
Lorenzo Colitti
1bc9ad0375 Add test coverage for NetworkAgent callbacks.
Tests the onNetworkCreated, onNetworkUnwanted and
onNetworkDisconnected callbacks, and the teardown delay timer.

Bug: 181941583
Test: atest --rerun-until-failure 500 ConnectivityServiceTest#testNetworkAgentCallbacks
Change-Id: If539cf5d01ba23193afab2433ed0ac4e7f0550ec
2021-03-29 21:33:11 +09:00
Lorenzo Colitti
6d88078151 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
a37eaff1ea Address comments on onBlockedStatusChanged(Network, int) CL.
Test: m
Bug: 165835257
Change-Id: I6d3007a1eac54ee6650b350aee56ed398a2c950d
2021-03-29 20:12:09 +09:00
Frank Li
8539ed6fd2 Merge changes from topic "NetworkAgent02"
* changes:
  Fix cannot success verify count of the networkAgent Config items on R device
  [TL02]Remove hidden API usage of NetworkAgent
2021-03-29 11:08:24 +00:00
lifr
f459c60984 Fix cannot success verify count of the networkAgent Config items on R
device

Test: atest CtsNetTestCasesLatestSdk:android.net.NetworkAgentConfigTest
Fix: 183474500
Change-Id: Ie0fd5ba816c390bfb7bc6512d896a88482c217ec
Merged-In: Ie0fd5ba816c390bfb7bc6512d896a88482c217ec
2021-03-29 15:36:32 +08:00
lifr
f1594291c4 [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
Junyu Lai
371bd281f5 Merge "Support Dual ViLTE stats" 2021-03-29 06:59:19 +00:00
Remi NGUYEN VAN
a99e50dbf7 Merge "Re-implement NetworkUtils#queryUserAccess." 2021-03-29 04:57:40 +00:00
Lorenzo Colitti
092af05525 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
Treehugger Robot
6d1437a596 Merge "Add network disconnected callback" 2021-03-26 05:47:33 +00:00
Chiachang Wang
3ffcb398e2 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
Lorenzo Colitti
9150b1ec95 Add unit tests for onBlockedStatusChanged(Network, int).
Bug: 165835257
Test: atest FrameworksNetTests
Change-Id: I0597df71aa94817835d7a2fb54bfcf9222a34b64
2021-03-26 02:37:20 +09:00
Lorenzo Colitti
60104f59a0 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
521169738c 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
87ac58016f 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
e6badefc33 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
c542ed20fa Merge "Add network created callback support" 2021-03-25 13:22:17 +00:00
Lucas Lin
3483ccf883 Merge "Add annotation for Vpn#getNetwork()" 2021-03-25 11:29:38 +00:00
Lucas Lin
0f114dff28 Merge "Remove the usage of NETID_UNSET from Vpn.java" 2021-03-25 11:29:17 +00:00
Lucas Lin
bcf2a79ec8 Merge "Expose some APIs from ConnectivityManager" 2021-03-25 11:29:08 +00:00
Lucas Lin
29ed3efbfe 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
fb0d390e6f 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
lucaslin
150976c603 Add annotation for Vpn#getNetwork()
- Add @VisibleForTesting & @Nullable for Vpn#getNetwork().
- Remove null check in caller side(test) of Vpn#getNetwork()
because if the code is working properly, it can never be null.

Bug: 182963397
Test: atest FrameworksNetTests
Change-Id: Ic52864003fbebd9f4e95d43fefc2e168437b0122
Merged-In: Ic52864003fbebd9f4e95d43fefc2e168437b0122
  (cherry-picked from ag/13946573)
2021-03-25 10:21:07 +00:00
lucaslin
6b49587384 Remove the usage of NETID_UNSET from Vpn.java
Modify Vpn#getNetId() to Vpn#getNetwork() and uses NETID_UNSET
when getNetwork() returns null in ConnectivityServiceTest.

Bug: 182963397
Test: atest FrameworksNetTests
Change-Id: I69d449705b1dc541287c72af8dc7705dc4733109
Merged-In: I69d449705b1dc541287c72af8dc7705dc4733109
  (cherry-picked from ag/13927650)
2021-03-25 10:19:05 +00:00
lucaslin
2b87890282 Add static for constant
Bug: 182963397
Test: atest IpConnectivityMetricsTest
Test: atest NetdEventListenerServiceTest
Change-Id: I3826b9efc3418a724bd3753b9ad573adc3343b72
Merged-In: I3826b9efc3418a724bd3753b9ad573adc3343b72
  (cherry-picked from ag/13975513)
2021-03-25 10:16:34 +00:00
lucaslin
e14573d25e Get NetworkCapabilities from NetworkCallback
Register network callback for all networks and record
NetworkCapabilities for every networks. Once onDnsEvent is
triggered, use the netId it passes in to find the corresponding
NetworkCapabilities instead of using netId to create a Network
object(hidden API) then get the NetworkCapabilities by
ConnectivityManager#getNetworkCapabilities.

Bug: 182963397
Test: m
Test: atest IpConnectivityMetricsTest
Test: atest NetdEventListenerServiceTest
Change-Id: I91d68ca33253831b78def1ddeb074ba944a5d6ad
Merged-In: I91d68ca33253831b78def1ddeb074ba944a5d6ad
  (cherry-picked from ag/13959432)
2021-03-25 10:16:20 +00:00
Chiachang Wang
823542095f 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
026a987e1e 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
2e68aa2e7a 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
Treehugger Robot
f652408e6c Merge "Use a longer test timeout in integration test" 2021-03-25 01:24:51 +00:00
Jayachandran Chinnakkannu
df448f6eaa Merge "Add 5G/NR QOS support" 2021-03-24 17:44:48 +00:00
Treehugger Robot
eb3ba19447 Merge "Move BLOCKED_REASON_* constants from NPMS into ConnectivityManager." 2021-03-24 17:22:50 +00:00
Sudheer Shanka
04aab0f60f 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
8ae3bf3f92 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
Junyu Lai
3ef6584f1b Merge "Fix cannot find removeUnwantedCapability on R device" 2021-03-23 12:16:18 +00:00
Chiachang Wang
2848cdf348 Merge "Correct the logic in NetworkCapabilitiesTest" 2021-03-23 11:46:31 +00:00
Chiachang Wang
08bebe4609 Merge "Add NetworkRequest.Builder creating from an existing instance" 2021-03-23 10:46:20 +00:00
junyulai
1ed0b04410 Fix cannot find removeUnwantedCapability on R device
Test: atest CtsNetTestCasesLatestSdk:android.net.NetworkCapabilitiesTest
Fix: 183473863
Merged-In: Icf2cda325795acee22a6c634e8d978f64c5ac3cb
Change-Id: Icf2cda325795acee22a6c634e8d978f64c5ac3cb
  (cherry-picked from ag/13966708)
2021-03-23 17:40:55 +08:00
Remi NGUYEN VAN
2c5c322eb9 Use a longer test timeout in integration test
One second to start the test NetworkStack service and obtain
a NetworkMonitor is too tight.

Change-Id: I3ac600276b6248c70c6239b0c9531913dc44096e
Test: atest ConnectivityServiceIntegrationTest
2021-03-23 09:33:16 +00:00
Chiachang Wang
29d00bc32d Correct the logic in NetworkCapabilitiesTest
setOwnerUid() and setAdministratorUids() should run in R+.
Previous logic will skip them in S+. Correct the logic to
what it should be.

Bug: 172183305
Test: atest android.net.NetworkCapabilitiesTest
Change-Id: Ic983aa00f930fb26350469ef093bcba2990433a4
2021-03-23 15:16:39 +08:00
Chiachang Wang
992047ed78 Add NetworkRequest.Builder creating from an existing instance
Provide a formal way to construct a new NetworkRequest from an
existing instance. The network capabilities inside the
NetworkRequest is hidden. There is no way to pass a
NetworkRequest and update its capabilities. Add
NetworkRequest.Builder creating from an existing instance to
allow to clone the network capabilities.

Bug: 172183305
Test: make update-api
Change-Id: I068462b2a1410daf67b0c95f2b643d396f079531
Merged-In: I068462b2a1410daf67b0c95f2b643d396f079531
2021-03-23 14:50:03 +08:00
Junyu Lai
20d187254b Merge "[VCN15] expose addUnwantedCapability and related APIs" 2021-03-23 05:02:22 +00:00