Commit Graph

117 Commits

Author SHA1 Message Date
Sooraj Sasindran
e7aee2736e Add a method to apply a set of network preferences to a user profile
Add a method to apply a set of network preferences to a user profile

Bug: 194332512
CTS-Coverage-Bug: 211133973
Test: CTS
Change-Id: I97730ea14e7c96922236fd77a591e5acadd875ba
2022-01-11 21:07:23 -08:00
markchien
738ad911c7 Add updateMeteredNetwork{Allow, Deny}List APIs
To deprecated below netd binder interfaces and move the functionality to
tethering(connectivity) mainline module:
  bandwidthAddNaughtyApp
  bandwidthRemoveNaughtyApp
  bandwidthAddNiceApp
  bandwidthRemoveNiceApp
Expose updateMeteredNetwork{Allow, Deny}List APIs to support the caller
outside the module. Currently the two APIs are still call to INetd
binders. Once functionality is moved to mainline module, will switch to
use them.

Bug: 209935649
Test: m
Change-Id: I8df720935748c2587f91a7b760cfd5a93a0fa852
2022-01-07 10:16:13 +08:00
Sooraj Sasindran
4196937bdd Add enterpriseSpecifier
Add enterpriseSpecifier to network capability

Bug: 194332512
CTS-Coverage-Bug: 211133973
Test: CTS and unit test.
Change-Id: If16c8e17cee71cc6788c43a8818bcca68a00bf99
2021-12-23 09:32:20 -08:00
Mingguang Xu
2d87c6152d Create DhcpOption object and make it a SystemApi
This allows OEM apps to pass their custom DHCP options for establishing
network connection.

Bug: 177278970

Test: atest FrameworksNetTests
Test: atest NetworkStackTests

Signed-off-by: Mingguang Xu <mingguangxu@google.com>
Change-Id: I2b8c38ee9a948ad6edb666312c989d27a8ff904b
2021-12-09 19:37:40 -08:00
paulhu
91e7806938 Update allowed on restricted networks getter/setter
As API review feedback, setting allowed on restricted networks
should be by uid instead of package name for security reason.
Thus, update the getter/setter to return/accept set of uids.

Bug: 188085693
Test: atest FrameworksNetTests
Merged-In: I979bf98075e6c9c0ed7e891582843fddb62643cb

Change-Id: I979bf98075e6c9c0ed7e891582843fddb62643cb
2021-05-27 16:24:50 +08:00
paulhu
257a5cf7ad Address [set|get]RestrictedAllowedApps API review feedback
- Rename [set|get]RestrictedAllowedApps to
  [set|get]AppsAllowedOnRestrictedNetworks
- Remove the regex of validate package name check

Bug: 188085693
Test: m update-api && m
Change-Id: I07966fb66093523a67e1e6a1ecfa05cc399e22f2
2021-05-14 15:27:36 +08:00
paulhu
344c11661f Update mobile data preference getter/setter
To satisfy OEM's requests, setting mobile data preference
should be by uid. Thus, update the getter/setter to
return/accept set of uids that need to apply mobile data
preference.

Bug: 171872461
Test: atest FrameworksNetTests
Change-Id: Id44efd2a6d820867f4405426c91e65b9ef155898
2021-05-13 10:35:29 +00:00
paulhu
69afcd51db Add RESTRICTED_ALLOWED_APPS setting
This setting is OEM upstream requirement for third party apps
using restricted networks.

Bug: 185149952
Test: atests FrameworksNetTests
Change-Id: I5e16b46cf2935f38ee1e516bb8b85fa487cf9f61
2021-05-13 10:09:31 +08:00
Lucas Lin
a23e55da49 Merge "Update PrivateDnsMode from StringDef to IntDef" 2021-05-12 17:09:50 +00:00
Lorenzo Colitti
395fafb54f Rename unwanted capabilities to forbidden capabilities.
Addresses API council feedback.

Bug: 184890428
Test: atest FrameworksNetTests CtsNetTestCases
Test: atest CtsNetTestCasesLatestSdk:NetworkCapabilitiesTest on R device
Change-Id: Id7c68fbf56ee08fcad8e8e3aacf037fa1885936b
2021-05-11 17:46:13 +09:00
lucaslin
57f9ba8b40 Update PrivateDnsMode from StringDef to IntDef
Update PrivateDnsMode from StringDef to IntDef because IntDef is
the normal way of representing multiple choices in public API.
Also update other related files.

Bug: 185311744
Test: 1. make update-api
      2. atest FrameworksNetTests CtsNetTestCases CtsNetTestCasesLatestSdk
      3. atest FrameworksServicesTests:DevicePolicyManagerTest
Change-Id: I23e7ec140066979726d769cabc5f7057bb2167e6
Merged-In: I23e7ec140066979726d769cabc5f7057bb2167e6
    (Cherry-picked from ag/14227609)
2021-05-05 03:19:51 +00:00
Treehugger Robot
984e51670e Merge "Rename getAllNetworkStateSnapshot which should be pluralized" 2021-04-29 04:40:51 +00:00
Chiachang Wang
9075ae36be Address API review feedback
Address API review feedback to:
 - Rename NetworkAgent#setTeardownDelayMs to
   NetworkAgent#setTeardownDelayMillis
 - Use getters instead of fields in VpnTransportInfo
 - Rename registerDefaultNetworkCallbackAsUid to
   registerDefaultNetworkCallbackForUid in ConnectiivityManager

Bug: 183972850
Bug: 185246410
Fix: 184735863
Test: make update-api
Test: atest FrameworksNetTests
Test: atest CtsNetTestCasesLatestSdk
Change-Id: I5e8c4bed8bda40d507afa894c359b5e24ee5d868
Merged-In: I5e8c4bed8bda40d507afa894c359b5e24ee5d868
2021-04-23 02:46:05 +00:00
Aaron Huang
da103b3365 Rename getAllNetworkStateSnapshot which should be pluralized
Address API review feedback, ConnectivityManager#getAllNetworkStateSnapshot
should be pluralized so rename the method to getAllNetworkStateSnapshots

(cherry picked from ag/14221105)
Bug: 183972554
Test: make, FrameworksNetTests
      FrameworksServicesTests
Merged-In: Ic18d17d05984fa2466c962c7843c0ef7183ce77c
Change-Id: Ic18d17d05984fa2466c962c7843c0ef7183ce77c
2021-04-22 17:45:22 +08:00
junyulai
8c8ac36d9a [VCN20] Change requestBackgroundNetwork argument order
Test: atest FrameworksNetTests FrameworksVcnTests
Fix: 185215095
Merged-In: Id281678fe85ce0894b0e92e11c0283d4d1b4ecdb
Change-Id: Id281678fe85ce0894b0e92e11c0283d4d1b4ecdb
  (cherry-picked from ag/14198667)
2021-04-16 00:16:21 +08:00
paulhu
c3663377e7 Remove TcpRepairWindow from module-lib API
Both TcpRepairWindow and TcpKeepaliveController(user) are in the
connectivity module, so TcpRepairWindow doesn't need to be
the module-lib API. Thus, remove TcpRepairWindow from
module-lib API.

Bug: 172183305
Test: m update-api
Change-Id: I8fde726f8ad73637e6deab69ea83b3699bb2cf45
2021-04-12 14:26:55 +08:00
Remi NGUYEN VAN
a2a324f843 Merge "Set ParseException constructors as public" 2021-04-09 00:20:33 +00:00
Remi NGUYEN VAN
58a22b1d8f Merge "Add RequiresPermission to TestNetworkManager" 2021-04-09 00:19:51 +00:00
Remi NGUYEN VAN
c5174c3c10 Add RequiresPermission to TestNetworkManager
All API methods in TestNetworkManager require the MANAGE_TEST_NETWORKS
permission.

Fixes: 183972672
Test: m
Change-Id: Ic5929c24ea88d7259d367a81fec8f223a2e3ecb0
2021-04-08 16:12:23 +09:00
Remi NGUYEN VAN
84a217a6ef Set ParseException constructors as public
As there is no strong reason to keep the constructors module-lib, set
them as public API.
This is in response to API feedback.

Fixes: 183446251
Test: m
Change-Id: I01daa6f6f8095f7a4db94d1ca05f913166939df3
2021-04-08 15:57:31 +09:00
paulhu
b49c8425b2 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
cb20318619 Merge "Expose constants of ConnectivityManager" 2021-04-07 10:11:06 +00:00
lucaslin
d89b2980df 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
Roshan Pius
fb309ae283 Merge "NetworkCapabilities: Hide copy constructor" 2021-04-06 15:57:47 +00:00
Roshan Pius
fc3adb5ae1 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
lifr
65b9f96159 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
lifr
b4dab37e28 [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
8ad5812ebc 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
7a4eeed62f 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
6865eb6dda 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
9443095517 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
Lucas Lin
8e4ae68ddd Merge "Expose some APIs from ConnectivityManager" 2021-03-25 11:29:08 +00:00
lucaslin
29278eef92 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
Sudheer Shanka
f1520bb8dc 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
Junyu Lai
84ebe6693a Merge "[VCN15] expose addUnwantedCapability and related APIs" 2021-03-23 05:02:22 +00:00
lucaslin
0e345e9b1a Have a new method in NetworkAgentConfig.Builder to set allowBypass
Have a new method in NetworkAgentConfig.Builder for Vpn to set
allowBypass.

Bug: 182963397
Test: m
Change-Id: I3f244464438325ee7f8a1b953d3fb28186293628
2021-03-23 09:01:40 +09:00
Lorenzo Colitti
b90bdbdbf4 Expose registerDefaultNetworkCallbackAsUid.
Bug: 165835257
Test: atest FrameworksNetTests
Change-Id: I638ed5cd5273d456919630aba1e22f099df1b36c
2021-03-22 19:50:27 +09:00
junyulai
b15b7dbdd4 [VCN15] expose addUnwantedCapability and related APIs
Test: m -j doc-comment-check-docs
Bug: 175662146
Merged-In: I3f2e6a99e015f09cc4405f6804eac4ae33e3dcc7
Change-Id: I3f2e6a99e015f09cc4405f6804eac4ae33e3dcc7
  (cherry-picked from ag/13929102)
2021-03-22 16:51:50 +08:00
Treehugger Robot
454f122745 Merge changes from topics "revert-1645768-revert-1626206-replaceUidRange-MSYTKFNGUE-HIUTVTIGIR", "ti_redaction"
* changes:
  TransportInfo: Add a generic redaction mechanism
  Revert "Revert "Expose uids related APIs in NetworkRequest and N..."
  Revert^2 "Replace the usage of UidRange"
2021-03-21 16:41:13 +00:00
Roshan Pius
e2d2838805 TransportInfo: Add a generic redaction mechanism
This replaces the existing mechanism for redacting location sensitive
fields with a more extensible mechanism. Currently supported redactions
are for the following permissions:
i. ACCESS_FINE_LOCATION
ii. LOCAL_MAC_ADDRESS
iii. NETWORK_SETTINGS

Also, removed WifiInfo from ConnectivityServiceTest to reduce cross
dependencies on wifi code.

Bug: 156867433
Bug: 162602799
Test: atest android.net
Test: atest com.android.server
Change-Id: I2bb980c624667a55c1383f13ab71b9b97ed6eeab
2021-03-19 20:15:21 +00:00
Chiachang Wang
1756295fc5 Merge "Add startCaptivePortalApp to system API" 2021-03-19 11:30:20 +00:00
Chiachang Wang
628cb1187e Revert "Revert "Expose uids related APIs in NetworkRequest and N..."
Revert^2 "Add shims for NetworkRequest"

b72b3ca768fc25ef72dc78f1396b08447b8ef5c6

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: I4b8e1aa558e3459a932535f9901f4ae86b0ecb67
Merged-In: I107c329d4d7130d488772166eae8b5e7aaa2ff04
2021-03-19 02:12:17 +00:00
Anthony Stange
35b926cc47 Merge changes from topic "revert-1626206-replaceUidRange-MSYTKFNGUE"
* changes:
  Revert "Replace the usage of UidRange"
  Revert "Expose uids related APIs in NetworkRequest and NetworkCa..."
2021-03-18 16:40:53 +00:00
Anthony Stange
fa6349a6c7 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
Remi NGUYEN VAN
8238a7665a Add startCaptivePortalApp to system API
The API is already used by settings and should be usable by setup
wizards. It is the only way for a caller outside of the system_server to
trigger the captive portal application.

The API is already CTS tested in android.net.cts.CaptivePortalTest.

Fixes: 182871577
Test: atest CtsNetTestCases:android.net.cts.CaptivePortalTest
Change-Id: Ie8d9a546b54524ba837715baa94a07d1f993d8d3
2021-03-18 22:41:00 +08:00
Lucas Lin
56564e061c Merge "Expose systemReady for SystemServer" 2021-03-18 13:40:54 +00:00
Chiachang Wang
268a9f56f2 Merge changes from topic "replaceUidRange"
* changes:
  Expose uids related APIs in NetworkRequest and NetworkCapabilities
  Replace the usage of UidRange
2021-03-18 13:36:39 +00:00
Chiachang Wang
e584943ca1 Merge "Expose APIs for Settings" 2021-03-18 13:27:47 +00:00
Chalard Jean
8c288603d1 Merge "Move constants to MODULE_LIB" 2021-03-18 12:29:38 +00:00
Chiachang Wang
f9294e7cd1 Expose APIs for Settings
ConnectivityManager will be a part of incoming connectivity
mainline. Settings will no longer to access the hidden methods.
For those methods that accept the interaction from users, they
should be exposed as formal interface to allow the
functionality. Expose them to API surface.

Bug: 172183305
Test: make update-api
Change-Id: Id4533b94291766bb060af0091b5ccb81a00630fd
2021-03-18 11:18:56 +08:00