Commit graph android_packages_modules_Co.../core/java
Message SHA1
Align coding style of line-wrapping in NetworkCapabilities
Test: TH
Change-Id: Ic864524a60954f8dbcce265643c2cb3ac3aefca8

junyulai   authored and   Junyu Lai   commited 2021-01-13 07:45:18 +00:00
fd20e05e1d
[VCN01] Add NOT_VCN_MANAGED capability
Add new capability to indicate whether a network is
managed by Virtual Carrier Network (VCN). This is needed
to identify networks between VCN managed network and
others. And this capability will be:
  1. mutable
  2. requestable
  3. set by default for network agents and requests
  4. allowed for test networks

Test: 1. atest FrameworksNetTests CtsNetTestCases
      2. adb shell dumpsys connectivity
      3. atest ConnectivityServiceTest#testLoseMutableAndRequestableCaps
Bug: 175662146

Change-Id: Ia5eeb3912a687164fa95d7ba5516fd73abca79ba

junyulai   commited 2021-01-13 11:05:40 +08:00
d0617de32c
Merge "Support for Venue URL and friendly name from Network agent"
Hai Shalom   authored and   Gerrit Code Review   commited 2021-01-13 01:54:05 +00:00
2208ba1089
Merge "Keep Vehicle internal network always up"
Tomasz Wasilczyk   authored and   Gerrit Code Review   commited 2021-01-12 22:40:50 +00:00
2d9d5b806e
Keep Vehicle internal network always up
Bug: 171801262
Test: Boot with and without overlay set and check ifconfig
Change-Id: I1fd332caf3e09924abcfec9c2c137363be7873e4

Tomasz Wasilczyk   commited 2021-01-12 10:33:38 -08:00
54605b8501
Merge "[VCN02] Make LingerTimer takes request Id instead of NetworkRequest"
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-01-12 08:59:04 +00:00
4f5abd7cec
Support for Venue URL and friendly name from Network agent
Extend CaptivePortalData with a member to hold the venue friendly
name. If CaptivePortalData is initialized by both the network
agent and Capport, merge the two objects to include the venue
friendly name and prioritize the venue URL from the network
agent.

Bug: 162783305
Test: atest ConnectivityServiceTest
Test: atest CtsNetTestCasesLatestSdk:CaptivePortalDataTest
Test: End-to-end test
Change-Id: I4fdf356be42237c5b6c0ae5bacfd3cec4726861b

Hai Shalom   commited 2021-01-11 18:45:34 -08:00
e58bdc6fd0
Revert "wifi: Add systemAPi:setSubscriberId in NetworkAgentConfig"
This reverts commit a37dda6024.

Reason for revert: After discussion, we prefer to add a field in NetworkCapabilities instead. Sorry for inconvenience.

Change-Id: I2e8840a797df9d1594f2b8b576bcd45beb184fca

Junyu Lai   authored and   junyulai   commited 2021-01-08 19:22:28 +08:00
777533d32b
Merge "wifi: Add systemAPi:setSubscriberId in NetworkAgentConfig"
Les Lee   authored and   Gerrit Code Review   commited 2021-01-08 00:54:51 +00:00
06dbf611af
Inform ConnectivityService about always-on VPN lockdown.
Currently, when an always-on VPN is set in lockdown mode, Vpn
configures prohibit UID rules in netd directly and does not
inform ConnectivityService of the fact.

This means that ConnectivityService cannot send NetworkCallbacks
that tells apps that they are blocked or unblocked. It also means
that ConnectivityService has to take the mVpns lock and call into
Vpn to allow synchronous APIs such as getActiveNetwork to return
BLOCKED if the app is blocked.

Move all this to ConnectivityService:
- Add a setRequireVpnForUids API to ConnectivityManager, and have
  that pass the routing rules to netd.
- Update VpnTest to expect calls to ConnectivityManager instead
  of to netd.
- Whenever setRequireVpnForUids is called, ensure that
  ConnectivityService sends onBlockedStatusChanged to the
  affected callbacks.
- Update existing unit tests to check for callbacks.
- Add a way to find the VPN that applies to a given UID without
  taking the VPN lock, by instead scanning all connected VPNs.
  Use this as a replacement for direct access to mVpns.

For simplicity, and in order to ensure proper ordering between
the NetworkCallbacks sent for VPNs connecting and disconnecting,
process blocked UID ranges on the handler thread. This means that
when setRequireVpnForUids returns, the rule changes might not
have been applied. This shouldn't impact apps using network
connectivity, but it might mean that apps setting an always-on
package, and then immediately checking whether networking is
blocked, will see a behaviour change.

Bug: 173331190
Fix: 175670887
Test: new test coverage in ConnectivityServiceTest
Test: atest MixedDeviceOwnerTest#testAlwaysOnVpn \
            MixedDeviceOwnerTest#testAlwaysOnVpnLockDown \
	    MixedDeviceOwnerTest#testAlwaysOnVpnAcrossReboot \
	    MixedDeviceOwnerTest#testAlwaysOnVpnPackageUninstalled \
	    MixedDeviceOwnerTest#testAlwaysOnVpnUnsupportedPackage \
	    MixedDeviceOwnerTest#testAlwaysOnVpnUnsupportedPackageReplaced \
	    MixedDeviceOwnerTest#testAlwaysOnVpnPackageLogged \
            MixedProfileOwnerTest#testAlwaysOnVpn \
            MixedProfileOwnerTest#testAlwaysOnVpnLockDown \
	    MixedProfileOwnerTest#testAlwaysOnVpnAcrossReboot \
	    MixedProfileOwnerTest#testAlwaysOnVpnPackageUninstalled \
	    MixedProfileOwnerTest#testAlwaysOnVpnUnsupportedPackage \
	    MixedProfileOwnerTest#testAlwaysOnVpnUnsupportedPackageReplaced \
	    MixedProfileOwnerTest#testAlwaysOnVpnPackageLogged \
            MixedManagedProfileOwnerTest#testAlwaysOnVpn \
            MixedManagedProfileOwnerTest#testAlwaysOnVpnLockDown \
	    MixedManagedProfileOwnerTest#testAlwaysOnVpnAcrossReboot \
	    MixedManagedProfileOwnerTest#testAlwaysOnVpnPackageUninstalled \
	    MixedManagedProfileOwnerTest#testAlwaysOnVpnUnsupportedPackage \
	    MixedManagedProfileOwnerTest#testAlwaysOnVpnUnsupportedPackageReplaced \
	    MixedManagedProfileOwnerTest#testAlwaysOnVpnPackageLogged
Test: atest FrameworksNetTests HostsideVpnTests \
            CtsNetTestCases:VpnServiceTest \
	    CtsNetTestCases:Ikev2VpnTest
Change-Id: Iaca8a7cc343aef52706cff62a7735f338cb1b772

Lorenzo Colitti   commited 2021-01-07 17:44:29 +09:00
3f54f106dd
Merge "Remove mobile provision design out from connectivity service"
Chiachang Wang   authored and   Gerrit Code Review   commited 2021-01-07 06:47:26 +00:00
5e2637741b
Remove mobile provision design out from connectivity service
In order to support ConnectivityService mainline, module should
not use hidden APIs. The logic to get mobile provision is moved
to telephony surface since it's only used by telephony.
Hence, remove the design out from Connectivity.

Bug: 175177794
Test: atest FrameworksNetTests
Change-Id: Ic3082fc1c4d7ac998f4e4cff1351e6829d500924

Chiachang Wang   commited 2021-01-07 06:46:40 +00:00
0fd8e45b53
Merge "Replace withCleanCallingIdentity with [clear|restore]CallingIdentity"
Lucas Lin   authored and   Gerrit Code Review   commited 2021-01-07 04:32:54 +00:00
8971ccf93e
Merge "Migrate away from AsyncChannel in NetworkAgent"
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2021-01-06 14:10:21 +00:00
62cf62e0d9
[VCN02] Make LingerTimer takes request Id instead of NetworkRequest
Currently, LingerTimer takes a NetworkRequest for internal use.
However, this is unnecessary since only request Id is used.

Thus, this patch allows subsequent patches to remove the need
of a NetworkRequest when creating a LingerTimer. And the output
of lingered requests is reduced to id instead of printing
content of requests.

Test: atest FrameworksNetTests
Bug: 175180558
Change-Id: I9106d0804f1083942e1fcaca842f547c0aee1840

junyulai   commited 2021-01-06 17:26:12 +08:00
70afb0c48b
Replace withCleanCallingIdentity with [clear|restore]CallingIdentity
To prevent using @hide method - withCleanCallingIdentity() from
mainline module, use clearCallingIdentity() &
restoreCallingIdentity() instead.

Bug: 172183305
Test: FrameworksNetTests, CtsNetTestCasesLatestSdk
Change-Id: Iccd492741a0a5b1c2531fc5fc1378933b65ae038

lucaslin   commited 2020-12-30 11:54:55 +08:00
be80138c19
wifi: Add systemAPi:setSubscriberId in NetworkAgentConfig
The wifi (mainline module) need to set the subscriberId for specific
wifi network.

Bug: 176396812
Test: TreeHugger
Change-Id: Ie97d3dad81c87d41a360558e91c83278595ff475

lesl   commited 2020-12-28 18:15:52 +08:00
a37dda6024
Migrate away from AsyncChannel in NetworkAgent
Use two oneway binder interfaces instead.
The interfaces post messages to handlers as was implemented before, but
provide a more strictly defined interface, with less hops between
NetworkAgent, AsyncChannel, and ConnectivityService.

The actual public interface is the NetworkAgent @SystemApi: the binder
interface is an internal implementation detail.

Test: atest FrameworksNetTests CtsNetTestCasesLatestSdk
Bug: 173574274
Merged-In: Ie364ab50f416e7821e70f4539a881eea828e1256

Change-Id: Ie364ab50f416e7821e70f4539a881eea828e1256

Remi NGUYEN VAN   commited 2020-12-25 03:54:19 +00:00
77b0c1c72c
Merge "Split NetworkUtils and NetworkUtilsInternal"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2020-12-23 01:19:27 +00:00
a6a8451077
Merge "Move module utils to the module package."
Chalard Jean   authored and   Gerrit Code Review   commited 2020-12-21 05:35:09 +00:00
090cbf27ab
[IT03] Add replacement methods for network activity
Reference for NMS in ConnectivityManager should be removed for
incoming CS mainline. The API for listening network activity
should not go into NMS. As an alternative, the registry requests
should be sent to CS and handled by CS. Add necessary alternative
in IConnectivityManger first. The detail implementation will be
added in the follow up commits.

Bug: 170598012
Test: m
Change-Id: If4d24b937feb88a61f22073af2f671cf20298364

Chiachang Wang   commited 2020-12-21 03:48:54 +00:00
4068dcbab0
Move module utils to the module package.
Test: FrameworksWifiTest FrameworksNetTest
Change-Id: If5d1e4a58fb2d6d9544e6d01995dabe445cf1f25
Merged-In: I067eeecd458c34b7f2fbfa439072682661ac750c

Chalard Jean   commited 2020-12-16 11:44:22 +09:00
79162540bf
Move phone ID to extra for action provision
Previously, the phone ID was appended to the broadcast in DCT and sent
to ConnectivityManager. Instead of sending both as an action, send the
phone ID as an extra instead to make the action a protected broadcast.

Test: manually verify a SecurityException when action provision is sent
Test: atest DcTrackerTest
Bug: 172459128
Change-Id: Ic4129def86949d7191d15056852718dadbd72fba
Merged-In: Ic4129def86949d7191d15056852718dadbd72fba

Sarah Chin   commited 2020-12-15 10:55:22 -08:00
cabcbffad8
Merge changes from topic "tcp_keepalive_fix"
* changes:
  Use API TcpKeepalivePacketData in ClientModeImpl
  Add TcpKeepalivePacketData to SystemApi

Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2020-12-15 09:02:55 +00:00
f278ef3b02
Merge "Remove hidden deprecated getActiveNetworkQuotaInfo"
Chiachang Wang   authored and   Gerrit Code Review   commited 2020-12-15 07:02:54 +00:00
75d25e51d5
Remove hidden deprecated getActiveNetworkQuotaInfo
getActiveNetworkQuotaInfo has never been in API surface since it
was introduced. It became essentially functionless since android O,
so there should be no usage dependency upon the hidden method,
In order to support ConnectivityService mainline, remove the
useless function to prevent necessary dependency.

Bug: 172183305
Test: atest FrameworksNetTests
Change-Id: Ia685b3260256d465ef614b2f577d13344074c787

Chiachang Wang   commited 2020-12-15 06:45:50 +00:00
2f81e75ae4
Add TcpKeepalivePacketData to SystemApi
This is consistent with NattKeepalivePacketData, which is also a
subclass of KeepalivePacketData.

TcpKeepalivePacketData is already used by the wifi module, but
statically linked.

Bug: 172789687
Test: m
Change-Id: I6aee1ae205987521bea4a3838bbece279ffa0e37

Remi NGUYEN VAN   commited 2020-12-14 18:43:44 +09:00
5e6b51b895
Merge "Expose TcpRepairWindow as module-lib API"
Paul Hu   authored and   Gerrit Code Review   commited 2020-12-11 05:37:10 +00:00
1c6da2593f
Merge changes from topic "remove_legacy_NA"
* changes:
  Remove support for legacy network agents
  Remove deprecated constructors for NetworkAgent
  Migrate NetworkAgentWrapper to the new NA API
  Cleanup TestNetworkService

Chalard Jean   authored and   Gerrit Code Review   commited 2020-12-11 02:32:57 +00:00
8e0446ba0a
Merge changes I6eb6d92b,I638e29fd,I2348b7a3
* changes:
  Add a convenience method to update a network's capabilities.
  Disallow NetworkAgents from changing the owner UID.
  Observe mOwnerUID in NetworkCapabilities#equals.

Lorenzo Colitti   authored and   Gerrit Code Review   commited 2020-12-10 08:11:52 +00:00
635e43ae1a
Observe mOwnerUID in NetworkCapabilities#equals.
Currently, NetworkCapabilities's equals and hashCode methods
ignore mOwnerUID. This is confusing because it is inconsistent
with pretty much every other member of this class.

Bug: 175188445
Test: atest CtsNetTestCases:NetworkAgentTest \
            CtsNetTestCases:Ikev2VpnTest \
	    CtsNetTestCases:VpnServiceTest HostsideVpnTests \
	    CtsNetTestCases:android.net.cts.ConnectivityDiagnosticsManagerTest \
	    ConnectivityServiceTest com.android.server.connectivity.VpnTest
Change-Id: I2348b7a35f32a931687f2d3c2fa57620a12fe06f

Lorenzo Colitti   commited 2020-12-09 19:33:32 +09:00
46fd589d89
Expose TcpRepairWindow as module-lib API
Connectivity service is going to become a mainline module which
will not be able to access hidden APIs. TcpKeepaliveController
is a part of CS mainline module, it uses TcpRepairWindow to
store tcp repair window info. Thus, expose TcpRepairWindow as
module-lib API to support the usage.

Bug: 172183305
Test: atest FrameworksNetTests
Change-Id: I1b6f5ae698f4b6e030a0f776aeafc774fa9f1437

paulhu   authored and   Paul Hu   commited 2020-12-09 08:25:13 +00:00
8516d85251
Remove support for legacy network agents
Test: FrameworksNetTests NetworkStackTests
Bug: 167544279
Change-Id: Ia950e16d991cd08d4b609d71aad61a4a4f7fda39

Chalard Jean   commited 2020-12-08 19:43:11 +09:00
dcac686b24
Remove deprecated constructors for NetworkAgent
Finally.

Now that mLegacy is always false, removing the support
for legacy agents, a follow-up change will remove
the member and all the associated code.

Test: FrameworksNetTests NetworkStackTests
Bug: 167544279
Change-Id: I6e2c27facdd3ecc232a0aa32bf57c33cb06f118e

Chalard Jean   commited 2020-12-08 19:43:11 +09:00
710e1dc25f
Split NetworkUtils and NetworkUtilsInternal
NetworkUtils is planned to move to a dedicated JAR for connectivity
classes, while NetworkUtilsInternal would stay in the
frameworks-minus-apex JAR, in the com.android.internal.net package.

Bug: 171540887
Test: m, boots, wifi working
      atest FrameworksNetTests
Change-Id: I3d38d72ad23a4bf84af823c7baeb6fed25c0665f

Remi NGUYEN VAN   commited 2020-12-07 19:41:49 +09:00
b293c47ac8
[Mainline Migration] Migrate NetworkUtils
Migrating makeStrings(), numericToInetAddress() APIs

Bug: 173089079
Test: atest FrameworksNetTests
Change-Id: Ie914fd41bc3ce16d07f5d2768b89ce805b9245a9

Serik Beketayev   commited 2020-12-06 22:33:04 -08:00
754c5be0f7
Merge "Use IPV6_MIN_MTU from NetworkConstants in Ikev2Vpn"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2020-12-04 02:05:01 +00:00
ebe3aee39a
Merge "Do not query CS in NetworkProvider constructor"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2020-12-03 01:48:01 +00:00
bfc3c02f34
Merge "Remove CaptivePortal deps on @hide MetricEvents"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2020-12-02 11:12:56 +00:00
8a157aaeee
Merge "Add ConnectivityManager.TYPE_PROXY to SystemApi"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2020-12-02 09:23:27 +00:00
58606c506b
Remove CaptivePortal deps on @hide MetricEvents
The legacy metrics are deprecated, and CaptivePortal is planned to move
to a connectivity-specific jar which cannot reference MetricsEvents.

Bug: 171540887
Test: m
Change-Id: I409375de3844a7fedef707cf9e19a106d82a8e3a

Remi NGUYEN VAN   commited 2020-12-02 13:17:09 +09:00
e391512cbb
Add ConnectivityManager.TYPE_PROXY to SystemApi
This follows other TYPE_* constants like TYPE_WIFI_P2P that are
@SystemApi or public.
TYPE_PROXY has a use-case for the system to set network policies based
on proxy network templates. Although network types are deprecated, that
use-case needs to be supported and significant amounts of network
management would need to be rewritten to stop using network types.

The constant needs to be API as ConnectivityManager is planned to move
out of framework.jar, so only its formal API will be available to the
system server.

Bug: 174436414
Test: m
Change-Id: I266ed6bc59f5eb72302afe14472c93933733c8f8

Remi NGUYEN VAN   commited 2020-11-30 19:23:45 +09:00
ee660cfd90
Use IPV6_MIN_MTU from NetworkConstants in Ikev2Vpn
Instead of sharing the constant from LinkProperties, use the already
defined constant in the NetworkConstants class.

This allows Ikev2VpnProfile to allow depending on non-public
LinkProperties APIs, as LinkProperties is planned to move to
framework-connectivity.

Bug: 174436414
Test: m
Change-Id: I594bb7e81bc7681799c16eff621a5ffd1b29624c

Remi NGUYEN VAN   commited 2020-11-30 17:18:51 +09:00
00c5e70471
Migrate VPN to the public NetworkAgent API.
On top of being a cleanup this is useful for the S Network
Selection project that will need to enrich the Network
Agent API, and as such should not have to support legacy
agents.

Test: FrameworksNetTests NetworkStackTests
Bug: 167544279
Change-Id: Id3e5f6e19829c64074cd6a52c5f950cee56b860b

Chalard Jean   commited 2020-11-30 16:15:18 +09:00
746cdc28af
Do not query CS in NetworkProvider constructor
ConnectivityService may not be available in a NetworkProvider
constructor, if it is created (but still unused) before
ConnectivityService starts.

As ConnectivityManager is only necessary in
declareNetworkRequestUnfulfillable, which should not be called often,
just query ConnectivityManager at that point.

This is necessary for VcnManagementService, which is started before
ConnectivityService and creates its NetworkProvider in its constructor.
Fortunately VcnManagementService does not call
declareNetworkRequestUnfulfillable at this point.

ConnectivityManager may be migrated to classic service getters that
cache "null" when the service was not available the first time it is
queried, so no system service must query it before it starts.

Bug: 171540887
Test: atest FrameworksNetTests:NetworkProviderTest
Change-Id: I8dadcd0e1360a9464192f330493e13aa69dd9fe2

Remi NGUYEN VAN   commited 2020-11-30 12:42:15 +09:00
d707e7f5ae
Allow tests to create TRANSPORT_TEST|TRANSPORT_VPN networks.
This CL allows an app that has the MANAGE_TEST_NETWORKS
permission to create test VPN networks.

The code enforces that such networks can never apply to any UIDs
and thus will never carry any traffic.

Bug: 173331190
Test: passes existing tests, moved tests pass
Change-Id: I5befea0e3b4b6dce4ca0c6a04471a055186b644c

Lorenzo Colitti   commited 2020-11-27 15:35:38 +09:00
f3963fa279
Move applying underlying caps from Vpn to ConnectivityService.
Add support to ConnectivityService to track underlying networks
directly instead of through the Vpn class.

1. Communicate all information necessary to propagate underlying
   network capabilities to ConnectivityService via NetworkAgent.
   This includes:
   a. Underlying networks:
      - Add SystemApi for NetworkAgent to declare its underlying
        networks to ConnectivityService, and use it in Vpn.
      - Add a new declaredUnderlyingNetworks member to
        NetworkAgentInfo and store the underlying networks in it.
	Move propagation of underlying network capabilities to
	mixInCapabilities, which is a natural place for it.
   b. "Always metered" bit:
      - Communicate this to ConnectivityService via the existing
        NOT_METERED capability. Store it in a new declaredMetered
	boolean in NetworkAgentInfo to separate it cleanly from
	the NOT_METERED bit in the capabilities, which depends on
	whether the underlying networks are metered or not. In
	order to ensure that this is only ever changed when a NC
	update is received from a NetworkAgent, define a new
	processCapabilitiesFromAgent similar to the existing
        processLinkPropertiesFromAgent.

2. Ensure that propagating underlying network capabilities does
   not read the VPN's NetworkCapabilities. In order to do this,
   ensure that all relevant information on underlying networks
   and metering is sent to ConnectivityService at NetworkAgent
   registration time. CS still calls Vpn#updateCapabilities when
   a user is added/removed, but that is deleted in a future CL.

3. Slightly generalize propagating underlying network
   capabilities because there may be other network types that
   also have underlying networks that aren't VPNs (e.g., VCN).
   - Introduce a new supportsUnderlyingNetworks() boolean method
     in NetworkAgentInfo.
   - Rename updateAllVpnsCapabilities to
     propagateUnderlyingNetworkCapabilities.

This commit does not move the actual logic of calculating the
underlying capabilities out of Vpn.java. That can be done in a
subsequent change once CS stops calling getUnderlyingNetworks().

This commit also does not modify any of the other code in CS that
directly accesses VPNs' underlying networks.

Bug: 173331190
Test: passes existing tests in ConnectivityServiceTest
Test: CTS test in r.android.com/1511114
Test: atest CtsNetTestCases:Ikev2VpnTest HostsideVpnTests
Change-Id: I5f76cb1aa4866efed3d5c4590e931fdb0e994f8d

Lorenzo Colitti   commited 2020-11-27 15:35:38 +09:00
129c01eabf
Merge "Expose MIN_MTU_V6 as a public, @hide constant"
Benedict Wong   authored and   Gerrit Code Review   commited 2020-11-20 01:30:18 +00:00
3b0f85c921
Merge "Clarify documentation on TEMP_NOT_METERED API"
Sarah Chin   authored and   Gerrit Code Review   commited 2020-11-19 17:50:35 +00:00
b4b3693558
Clarify documentation on TEMP_NOT_METERED API
Test: build
Bug: 165337240
Change-Id: Ifc0843b529e7a205b0e1caf98420adfc377c28e7

Sarah Chin   commited 2020-11-19 01:15:48 -08:00
2cb619acfd