Commit Graph

11504 Commits

Author SHA1 Message Date
Remi NGUYEN VAN
58606c506b Merge "Add ConnectivityManager.TYPE_PROXY to SystemApi" 2020-12-02 09:23:27 +00:00
Xin Li
468855a0b0 Merge rvc-qpr-dev-plus-aosp-without-vendor@6881855
Bug: 172690556
Merged-In: I78222391b83a4add8e964340ec08bb8a1306e1c6
Change-Id: I28bbf40820674675ccf765c912aa8140d3f74ab2
2020-12-02 00:38:58 -08:00
Lorenzo Colitti
4f3407d297 Merge changes Ic5a3e169,I76daa3ab am: c54b7eda99
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1512888

Change-Id: Ibc9ad6c89e1214302b92118a01a924fa1481767e
2020-12-02 05:23:05 +00:00
Lorenzo Colitti
c54b7eda99 Merge changes Ic5a3e169,I76daa3ab
* changes:
  Refactor applyUnderlyingCapabilities and its test.
  Move applyUnderlyingCapabilities to ConnectivityService.
2020-12-02 04:55:12 +00:00
Remi NGUYEN VAN
e391512cbb 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
2020-12-02 13:17:09 +09:00
Lucas Lin
9e0129515b Merge "Use public API of NetworkAgent in TestNetworkService" am: 8671a6fe9e
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1505291

Change-Id: If37614f211ea2cddb98f06b95b9dfe32e5a98cb5
2020-12-02 03:58:08 +00:00
Lucas Lin
8671a6fe9e Merge "Use public API of NetworkAgent in TestNetworkService" 2020-12-02 03:30:59 +00:00
Treehugger Robot
3da59ba9e3 Merge "Deprecated UserManager.getUsers(excludeDying) / added getAliveUsers()" am: c0b44fca8b
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1406256

Change-Id: I6d0d919ddad282d526c2412efdd92e368149ab87
2020-12-01 17:32:56 +00:00
Lorenzo Colitti
d7caf838c0 Refactor applyUnderlyingCapabilities and its test.
This reduces verbose assertions and makes the test more compact.
I'm not sure whether it's actually more valuable, since the
current code, while more verbose, is probably more
straightforward to understand.

Also add a test for passing in a null underlying network (i.e.,
follow default network). This requires a minor refactoring in
ConnectivityService because the applyUnderlyingCapabilities does
not currently treat null specially.

Bug: 173331190
Test: test-only change
Change-Id: Ic5a3e16969ea9e1a529706850f148cb0d5fd8e09
2020-12-02 00:45:57 +09:00
lucaslin
4ead42c078 Use public API of NetworkAgent in TestNetworkService
- Create NetworkAgent by using the public API of NetworkAgent.
- Remove the usage of NetworkInfo.

Bug: 172183305
Test: Build pass.
Test: atest FrameworksNetTests
Test: atest CtsNetTestCasesLatestSdk
Test: atest NetworkStackIntegrationTests
Test: atest TetheringIntegrationTests
Change-Id: Icba59295861201c221587caa9df02275c4087fb8
2020-12-01 23:03:02 +08:00
Lorenzo Colitti
cda101be7d Move applyUnderlyingCapabilities to ConnectivityService.
This is essentially a straighforward move of code from Vpn to
ConnectivityService, and from VpnTest to ConnectivityServiceTest.

Bug: 173331190
Test: passes existing tests, moved tests pass
Change-Id: I76daa3abcc777e9c3ba57efb750de0e2e2f3bb74
2020-12-01 23:23:47 +09:00
Felipe Leme
11cf60b2c5 Deprecated UserManager.getUsers(excludeDying) / added getAliveUsers()
The existing method is confusing (the argument used to be called
includeDying) and it puts the burden on the caller (which need to
understand what the parameter means).

Furthermore:

- The majority of calls are for getUsers(excludeDying=true).
- The calls for getUsers(excludeDying=false) are equivalent to
  calls to getUsers()

Test: m
Test: a VpnTest ConnectivityServiceTest PermissionMonitorTest

Bug: 157921703
Change-Id: Ife767a40b7b7790ba28b5377046de822ddbf275c
Merged-In: Ife767a40b7b7790ba28b5377046de822ddbf275c
(cherry picked from commit 6dc6d2b96498bcca132913dbfc6338f8f9f6c697)
2020-12-01 15:25:52 +08:00
Remi NGUYEN VAN
2946cfe8d4 Merge "Run OemNetworkPreferencesTest with DevSdkIgnoreRunner" am: f2d92dc1ee
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1512665

Change-Id: I48f1f591f9da798f5c154314c6cf00d504e9f435
2020-12-01 01:57:43 +00:00
Remi NGUYEN VAN
f2d92dc1ee Merge "Run OemNetworkPreferencesTest with DevSdkIgnoreRunner" 2020-12-01 01:33:42 +00:00
Patrick Rohr
660722501f Add Restricted Mode Firewall Chain
Adding new allowlist firewall chain to support restricted networking
mode. See go/restricted-networking-mode.

Bug: b/157505406
Bug: b/170323408
Test: atest NetworkManagementServiceTest
Change-Id: I8e39b3d7b129ad74224d0c1311135b7b48f6514f
2020-11-30 18:36:02 +01:00
Patrick Rohr
f8fedc34b0 Clean Up NetworkManagementService Tests
Cleaning up tests, so I can easily add more for restricted networking
mode.
I merged the NetworkManagementInternalTests with the
NetworkManagementServiceTests.

Test: atest NetworkManagementServiceTest
Change-Id: If8c3cc1883cfb2524eeb78e23165fc868130f0e7
2020-11-30 18:35:44 +01:00
Lorenzo Colitti
f044795629 Merge changes If2201f39,Ia1c366c5 am: 5dab5fb9c4
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1509889

Change-Id: I6ad54ba833d242ed790123c381a308ef678e4d4d
2020-11-30 15:01:45 +00:00
Lorenzo Colitti
5dab5fb9c4 Merge changes If2201f39,Ia1c366c5
* changes:
  Stop calling Vpn#updateCapabilities in CS.
  Stop accessing VPNs in checkConnectivityDiagnosticsPermissions.
2020-11-30 14:14:38 +00:00
Lorenzo Colitti
a2f800ca78 Merge changes I982543cd,I41c3bf6c,Id3e5f6e1 am: 4f42110c4f
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1511316

Change-Id: Iac22dfcf6550233df7dc7c33689cb797503e24f9
2020-11-30 13:54:52 +00:00
Lorenzo Colitti
4f42110c4f Merge changes I982543cd,I41c3bf6c,Id3e5f6e1
* changes:
  Add a provider to VPN
  Small VPN cleanup
  Migrate VPN to the public NetworkAgent API.
2020-11-30 13:48:26 +00:00
Remi NGUYEN VAN
ee660cfd90 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
2020-11-30 19:23:45 +09:00
Remi NGUYEN VAN
00c5e70471 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
2020-11-30 17:18:51 +09:00
Chalard Jean
c99d746c06 Add a provider to VPN
Test: FrameworksNetTests NetworkStackTests
Change-Id: I982543cdee358bb62d3b56a7fd9d71dc18908b65
2020-11-30 16:15:19 +09:00
Chalard Jean
746cdc28af 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
2020-11-30 16:15:18 +09:00
Aaron Huang
6616df39b9 Migrate Slog to Log used in connectivity service module
Connectivity service module uses Slog which is @hide so
migrate to Log, which is public, to remove hidden API usage.

Bug: 172050541
Test: FrameworksNetTests
      check log is moved from system buffer to main buffer.
Change-Id: I0dcc0e169b892cc872ed4510f699642cb81b633a
2020-11-30 14:35:01 +08:00
Remi NGUYEN VAN
d707e7f5ae 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
2020-11-30 12:42:15 +09:00
Treehugger Robot
47ec892104 Merge "Adding @IgnoreUpTo to OemNetworkPreferencesTest" am: e794a09bb7
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1511772

Change-Id: Ie7cf35131d553279ccd3244536107c2a0c53b379
2020-11-30 02:08:29 +00:00
Remi NGUYEN VAN
e07a894bc3 Run OemNetworkPreferencesTest with DevSdkIgnoreRunner
The class-level @IgnoreUpTo annotation only applies with that runner.

Change-Id: I065618f2345c1d91de2fa1f2f558e5ed5b066f3e
Fixes: 174268969
Bug: 171505922
Test: atest FrameworksNetTests:android.net.OemNetworkPreferencesTest
2020-11-30 01:42:24 +00:00
Treehugger Robot
e794a09bb7 Merge "Adding @IgnoreUpTo to OemNetworkPreferencesTest" 2020-11-30 01:38:19 +00:00
Lorenzo Colitti
f295719210 Merge changes from topic "networkagent-set-underlying-networks" am: dccf7eda5e
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1501816

Change-Id: I94fd855f9b03d7487b1ebc8288be7f95e12fbe4f
2020-11-28 03:34:26 +00:00
Lorenzo Colitti
054f6c19b5 Clear calling identity in registerNetworkAgent. am: 8000e03ec9
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1511317

Change-Id: I0f93630527cfe352f5d8f5c69b5276dadbb8c3e4
2020-11-28 03:27:05 +00:00
Lorenzo Colitti
60dbe043ae Allow tests to create TRANSPORT_TEST|TRANSPORT_VPN networks. am: f3963fa279
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1511312

Change-Id: Id28ea9f3b72e5cae0232ffc7698120512359be49
2020-11-28 03:24:32 +00:00
Lorenzo Colitti
298ce37539 Move applying underlying caps from Vpn to ConnectivityService. am: 129c01eabf
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1501815

Change-Id: I10147f9b86661243e654a16a760e183128493042
2020-11-28 03:20:40 +00:00
Lorenzo Colitti
18b00acd92 Stop calling Vpn#updateCapabilities in CS.
Instead, make Vpn#onUserAdded and Vpn#onUserRemoved notify CS
of UID range changes through the VPN's NetworkAgent.

After this change, ConnectivityService no longer touches the
VPN's NetworkCapabilities directly, which is a much cleaner
design.

Bug: 173331190
Test: passes existing tests in ConnectivityServiceTest
Change-Id: If2201f392cdb5f00c89a97683ad4ce6bda7b89e5
2020-11-27 15:35:39 +09:00
Lorenzo Colitti
fee5e4e34c Stop accessing VPNs in getAllVpnInfo.
This is only used for NetworkStatsService and only called on the
handler thread, so it can be replaced by a simple scan over
mNetworkAgentInfos without having to take any locks.

Bug: 173331190
Test: passes existing tests in ConnectivityServiceTest
Change-Id: I194e0cc55603a0f59f7138f38329f505b55da132
2020-11-27 15:35:38 +09:00
Lorenzo Colitti
8000e03ec9 Clear calling identity in registerNetworkAgent.
Much of registerNetworkAgent calls internal ConnectivityService
methods which generally assume that they are not processing an
IPC and are running under the system's calling identity.

However, only the call to makeNetworkMonitor is run with caller
identity cleared. Expand the scope of clearing the caller
identity over the creation of the nai.

Bug: 173331190
Test: passes existing tests in ConnectivityServiceTest
Change-Id: Icad28601a612fb5e1ed0451ec9e2066f4e766d0e
2020-11-27 15:35:38 +09:00
Lorenzo Colitti
f3963fa279 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
2020-11-27 15:35:38 +09:00
Lorenzo Colitti
129c01eabf 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
2020-11-27 15:35:38 +09:00
Lorenzo Colitti
083b00b5fb Stop accessing VPNs in checkConnectivityDiagnosticsPermissions.
Currently, checkConnectivityDiagnosticsPermissions takes the VPN
lock to examine the VPN's underlying networks. Use the underlying
network data that is available in ConnectivityService instead.

Bug: 173331190
Test: passes existing tests in ConnectivityServiceTest
Change-Id: Ia1c366c5e9974d4d2c4b38030e66c007d62020ff
2020-11-27 15:35:38 +09:00
Treehugger Robot
cdf25a7bf4 Merge changes Id4632e1b,I31985822,Ibbf96a25 am: 30b0d06a86
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1511309

Change-Id: Iabe10bcb42333e1046add1be5090c19733b7887d
2020-11-26 03:58:57 +00:00
Treehugger Robot
30b0d06a86 Merge changes Id4632e1b,I31985822,Ibbf96a25
* changes:
  Test passing an underlying network array with null network in it.
  Make testVpnNetworkActive more deterministic.
  Add a test for restricted profile added/removed with VPN up.
2020-11-26 03:40:44 +00:00
Lorenzo Colitti
6ae6681892 Test passing an underlying network array with null network in it.
Current code treats these nulls as if they weren't there.

Bug: 173331190
Test: test-only change
Change-Id: Id4632e1b004c09910b4b7613f7233d2c19e2f0ac
2020-11-26 10:33:23 +09:00
Lorenzo Colitti
b7769533c1 Make testVpnNetworkActive more deterministic.
This test is a bit brittle because it sets the underlying
networks while the VPN is undergoing validation by
NetworkMonitor. The test does attempt to disable validation,
but that's not actually possible - the only thing that's possible
is to tell NetworkMonitor to validate immediately without sending
any probes. So the underlying network change races with the
validation. I'm not sure why the test isn't flaky. It might be
because both the network change and the validation result in a
capabilities change, and the test expects "a capabilities change"
without expressing what change that should be.

Make this a bit more predictable by ensuring that the network
validates before the underlying networks are set.

This is useful because an upcoming CL will change the way
underlying network capabilities are propagated. With this test
CL, both the old and the new code pass.

Bug: 173331190
Test: test-only change
Change-Id: I319858228e8d097c0b60a107029f296385f91269
2020-11-26 10:33:23 +09:00
Lorenzo Colitti
99fb6920f6 Add a test for restricted profile added/removed with VPN up.
Bug: 173331190
Test: test-only change
Change-Id: Ibbf96a259a73068d110a159d54059720121117cc
2020-11-26 10:33:23 +09:00
James Mattis
b5cc74279d Adding @IgnoreUpTo to OemNetworkPreferencesTest
Adding @IgnoreUpTo to OemNetworkPreferencesTest so that it can run as
part of MTS.

Bug: 174268969
Bug: 171505922
Test: atest FrameworksNetTests:android.net.OemNetworkPreferencesTest
Change-Id: If7fb039c2cdb061f803c8a59e826e485e1f1c761
2020-11-25 15:34:11 -08:00
paulhu
7f9b6d0f31 Address leftover comments
Address leftover comments on aosp/1458063 and aosp/1470942.

Bug: 170593746
Test: atest FrameworksNetTests
Change-Id: If23a791731ca2034429a14c869902363dd657248
2020-11-25 15:14:09 +08:00
Lucas Lin
f69ea04ab1 Merge "Ignore verifying canBeSatisfiedBy() on Android Q" am: 7d013abf65
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1508137

Change-Id: Ia287b39a2f7d9a5b1ef9baf60bcf90048d66af7b
2020-11-24 04:16:28 +00:00
Lucas Lin
7d013abf65 Merge "Ignore verifying canBeSatisfiedBy() on Android Q" 2020-11-24 03:38:34 +00:00
lucaslin
1d8505b456 Ignore verifying canBeSatisfiedBy() on Android Q
The method - satisfiedBy() has changed to canBeSatisfiedBy()
starting from Android R, so the method - canBeSatisfiedBy()
cannot be found when running this test on Android Q.
Ignore verifying canBeSatisfiedBy() on Android Q to fix this
problem.

Bug: 173911834
Test: Run MatchAllNetworkSpecifierTest on Android Q, R, S.
Change-Id: Ibe317b56f82d3ea100b1d78c3907dce4f2fd964d
2020-11-23 23:40:23 +08:00
James Mattis
844c7cf2ed Merge changes Ibed6cdd4,I51e3c00d,Ibf37f94b am: 5cbbbfb144
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1498660

Change-Id: Idb3243ae752270a66b32acd0b8a3cc5161e695b2
2020-11-21 00:54:09 +00:00