Commit graph

13,045 commits

Message SHA1
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
fd64bac5b6
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

Aaron Huang   commited 2020-11-30 14:35:01 +08:00
11e9a31bac
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
7820e22137
Merge "Adding @IgnoreUpTo to OemNetworkPreferencesTest" am: 9a9e45ad72 am: b32ead42ae
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1511772

Change-Id: I6d89952b92960388319c516858ffbc08fd69b058

Treehugger Robot   authored and   Automerger Merge Worker   commited 2020-11-30 02:24:57 +00:00
ef777466b6
Merge "Adding @IgnoreUpTo to OemNetworkPreferencesTest" am: 9a9e45ad72
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1511772

Change-Id: Ie7cf35131d553279ccd3244536107c2a0c53b379

Treehugger Robot   authored and   Automerger Merge Worker   commited 2020-11-30 02:08:29 +00:00
b32ead42ae
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

Remi NGUYEN VAN   commited 2020-11-30 01:42:24 +00:00
535d328def
Merge "Adding @IgnoreUpTo to OemNetworkPreferencesTest"
Treehugger Robot   authored and   Gerrit Code Review   commited 2020-11-30 01:38:19 +00:00
9a9e45ad72
Merge changes from topic "networkagent-set-underlying-networks" am: dccf7eda5e am: b428266cd1
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1501816

Change-Id: I9c360de7101c0332360186055f915e0de6aba574

Lorenzo Colitti   authored and   Automerger Merge Worker   commited 2020-11-28 04:09:19 +00:00
d2e2a4a639
Clear calling identity in registerNetworkAgent. am: 4b1cd16a76 am: 964f7c7e4d
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1511317

Change-Id: Ia731c724f32a52d609db513f07ac4615343ee0ad

Lorenzo Colitti   authored and   Automerger Merge Worker   commited 2020-11-28 04:09:14 +00:00
7c00b2f055
Allow tests to create TRANSPORT_TEST|TRANSPORT_VPN networks. am: 4b4fcc7a72 am: 04c831319e
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1511312

Change-Id: Ib262f33cf2f467bf6610e2910d96fbcacb733a54

Lorenzo Colitti   authored and   Automerger Merge Worker   commited 2020-11-28 04:09:11 +00:00
bb06c82637
Move applying underlying caps from Vpn to ConnectivityService. am: 220987b38d am: a27c332849
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1501815

Change-Id: I8f4dc858bf45095102b583f528eac296637132b4

Lorenzo Colitti   authored and   Automerger Merge Worker   commited 2020-11-28 04:09:07 +00:00
ed3589c104
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

Lorenzo Colitti   authored and   Automerger Merge Worker   commited 2020-11-28 03:34:26 +00:00
b428266cd1
Clear calling identity in registerNetworkAgent. am: 4b1cd16a76
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1511317

Change-Id: I0f93630527cfe352f5d8f5c69b5276dadbb8c3e4

Lorenzo Colitti   authored and   Automerger Merge Worker   commited 2020-11-28 03:27:05 +00:00
964f7c7e4d
Allow tests to create TRANSPORT_TEST|TRANSPORT_VPN networks. am: 4b4fcc7a72
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1511312

Change-Id: Id28ea9f3b72e5cae0232ffc7698120512359be49

Lorenzo Colitti   authored and   Automerger Merge Worker   commited 2020-11-28 03:24:32 +00:00
04c831319e
Move applying underlying caps from Vpn to ConnectivityService. am: 220987b38d
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1501815

Change-Id: I10147f9b86661243e654a16a760e183128493042

Lorenzo Colitti   authored and   Automerger Merge Worker   commited 2020-11-28 03:20:40 +00:00
a27c332849
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

Lorenzo Colitti   commited 2020-11-27 15:35:39 +09:00
aceffad3b2
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

Lorenzo Colitti   commited 2020-11-27 15:35:38 +09:00
db20f89e6d
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

Lorenzo Colitti   commited 2020-11-27 15:35:38 +09:00
4b1cd16a76
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
4b4fcc7a72
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
220987b38d
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

Lorenzo Colitti   commited 2020-11-27 15:35:38 +09:00
82f9a007c1
Merge changes Id4632e1b,I31985822,Ibbf96a25 am: b459e5166d am: 7814aeda39
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1511309

Change-Id: I56294df5aa7773f9ed2caab4e14ed2a77b8f2a10

Treehugger Robot   authored and   Automerger Merge Worker   commited 2020-11-26 05:11:03 +00:00
22c43689ce
Merge changes Id4632e1b,I31985822,Ibbf96a25 am: b459e5166d
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1511309

Change-Id: Iabe10bcb42333e1046add1be5090c19733b7887d

Treehugger Robot   authored and   Automerger Merge Worker   commited 2020-11-26 03:58:57 +00:00
7814aeda39
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.

Treehugger Robot   authored and   Gerrit Code Review   commited 2020-11-26 03:40:44 +00:00
b459e5166d
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

Lorenzo Colitti   commited 2020-11-26 10:33:23 +09:00
c64d177ed9
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

Lorenzo Colitti   commited 2020-11-26 10:33:23 +09:00
621f5a9e8f
Add a test for restricted profile added/removed with VPN up.
Bug: 173331190
Test: test-only change
Change-Id: Ibbf96a259a73068d110a159d54059720121117cc

Lorenzo Colitti   commited 2020-11-26 10:33:23 +09:00
97ade70ce8
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

James Mattis   commited 2020-11-25 15:34:11 -08:00
c5b14c2b8a
Address leftover comments
Address leftover comments on aosp/1458063 and aosp/1470942.

Bug: 170593746
Test: atest FrameworksNetTests
Change-Id: If23a791731ca2034429a14c869902363dd657248

paulhu   commited 2020-11-25 15:14:09 +08:00
9fc05cecab
Merge "Ignore verifying canBeSatisfiedBy() on Android Q" am: dad3c929a3 am: 8203949d52
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1508137

Change-Id: I473bf0f260309a9b1a30b1957714032f1f06b9f6

Lucas Lin   authored and   Automerger Merge Worker   commited 2020-11-24 04:37:14 +00:00
828066d4ea
Merge "Ignore verifying canBeSatisfiedBy() on Android Q" am: dad3c929a3
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1508137

Change-Id: Ia287b39a2f7d9a5b1ef9baf60bcf90048d66af7b

Lucas Lin   authored and   Automerger Merge Worker   commited 2020-11-24 04:16:28 +00:00
8203949d52
Merge "Ignore verifying canBeSatisfiedBy() on Android Q"
Lucas Lin   authored and   Gerrit Code Review   commited 2020-11-24 03:38:34 +00:00
dad3c929a3
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

lucaslin   commited 2020-11-23 23:40:23 +08:00
aa00183916
Merge changes Ibed6cdd4,I51e3c00d,Ibf37f94b am: 6e4b94388a am: d7bc7d7e29
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1498660

Change-Id: Ie8d1a80486061a6ba2ca6a5f58c0e92201b8da6f

James Mattis   authored and   Automerger Merge Worker   commited 2020-11-21 01:28:23 +00:00
0905ca74db
Merge changes Ibed6cdd4,I51e3c00d,Ibf37f94b am: 6e4b94388a
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1498660

Change-Id: Idb3243ae752270a66b32acd0b8a3cc5161e695b2

James Mattis   authored and   Automerger Merge Worker   commited 2020-11-21 00:54:09 +00:00
d7bc7d7e29
Merge changes Ibed6cdd4,I51e3c00d,Ibf37f94b
* changes:
  Update toString() to use the correct request
  Update requestsSortedById() to sort by collection
  Allow a way to track the active request in an NRI

James Mattis   authored and   Gerrit Code Review   commited 2020-11-21 00:24:11 +00:00
6e4b94388a
Merge changes from topic "move_BSCH" am: f383d088a5 am: e757414483 am: 3c5243c309
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1503395

Change-Id: I09068be6ac4d220c3e9e9242f3e0eb2cf5d01e23

Chiachang Wang   authored and   Automerger Merge Worker   commited 2020-11-20 09:04:31 +00:00
f645c0e447
Move BasicShellCommandHandler to frameworks/lib/modules-utils am: 2d7e03cd61 am: 7f0b4d266e am: 30a6c316d0
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1483965

Change-Id: Ib09544e292d472e8dcd7dcf218035a0ec6de293c

Chiachang Wang   authored and   Automerger Merge Worker   commited 2020-11-20 09:04:26 +00:00
1b3dbf900a
Merge changes from topic "move_BSCH" am: f383d088a5 am: e757414483
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1503395

Change-Id: I3c14ab887a0c8529f17b9ed1eb49e1d01bc02be1

Chiachang Wang   authored and   Automerger Merge Worker   commited 2020-11-20 08:21:56 +00:00
3c5243c309
Move BasicShellCommandHandler to frameworks/lib/modules-utils am: 2d7e03cd61 am: 7f0b4d266e
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1483965

Change-Id: I0c01c2355d990e6e819ba6ac368ead2166f068f4

Chiachang Wang   authored and   Automerger Merge Worker   commited 2020-11-20 08:21:53 +00:00
30a6c316d0
Merge changes from topic "move_BSCH" am: f383d088a5
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1503395

Change-Id: I1e27a7fcde0ba83ffcad525ca091af7fc5ced2db

Chiachang Wang   authored and   Automerger Merge Worker   commited 2020-11-20 07:49:31 +00:00
e757414483
Move BasicShellCommandHandler to frameworks/lib/modules-utils am: 2d7e03cd61
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1483965

Change-Id: Ib2a99f1aeb31b89e69a5b313ca3774ba145dde33

Chiachang Wang   authored and   Automerger Merge Worker   commited 2020-11-20 07:47:11 +00:00
7f0b4d266e
Merge changes from topic "move_BSCH"
* changes:
  Remove BasicShellCommandHandler from frameworks/base
  Move BasicShellCommandHandler to frameworks/lib/modules-utils

Chiachang Wang   authored and   Gerrit Code Review   commited 2020-11-20 07:29:56 +00:00
f383d088a5
Merge "Expose MIN_MTU_V6 as a public, @hide constant" am: 26aa9c68f7 am: f7e4ee16aa am: b4ad0c6822
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1505072

Change-Id: I0b91313fdf767e66200b61d74f7d59f5128411d2

Benedict Wong   authored and   Automerger Merge Worker   commited 2020-11-20 02:31:18 +00:00
be4ea27157
Merge "Remove a comment from ConnectivityService" am: 21b62782dd am: b80c635dc3 am: 59af781c54
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1494040

Change-Id: I37083babeee918dc1b8653bd5908e71bcdb3e028

Lucas Lin   authored and   Automerger Merge Worker   commited 2020-11-20 02:28:56 +00:00
4edbf528ce
Merge "Expose MIN_MTU_V6 as a public, @hide constant" am: 26aa9c68f7 am: f7e4ee16aa
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1505072

Change-Id: I9c0715a6028e4a8deb66a63f656006c2949c5e81

Benedict Wong   authored and   Automerger Merge Worker   commited 2020-11-20 02:11:42 +00:00
b4ad0c6822
Merge "Remove a comment from ConnectivityService" am: 21b62782dd am: b80c635dc3
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1494040

Change-Id: I5438ae75425761d4f25123b52f3329f272145c14

Lucas Lin   authored and   Automerger Merge Worker   commited 2020-11-20 02:11:32 +00:00
59af781c54
Merge "Expose MIN_MTU_V6 as a public, @hide constant" am: 26aa9c68f7
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1505072

Change-Id: I9ef7cc8f84d6a9a49d754b39cc2bd66209d6343f

Benedict Wong   authored and   Automerger Merge Worker   commited 2020-11-20 01:38:30 +00:00
f7e4ee16aa
Merge "Remove a comment from ConnectivityService" am: 21b62782dd
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1494040

Change-Id: I20fa62c5dbe2d1e8e9cce19a8fb9a932f21722f7

Lucas Lin   authored and   Automerger Merge Worker   commited 2020-11-20 01:34:29 +00:00
b80c635dc3
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
26aa9c68f7