Commit Graph

12161 Commits

Author SHA1 Message Date
Treehugger Robot
acd938821f [automerger skipped] Merge "Deprecated UserManager.getUsers(excludeDying) / added getAliveUsers()" am: c0b44fca8b am: 902918a433 am: 96cd149dfb -s ours
am skip reason: Change-Id Ife767a40b7b7790ba28b5377046de822ddbf275c with SHA-1 72eeb557e7 is in history

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1406256

Change-Id: I93a7443dabeb35e8ab6e32004730f99e2fc49d69
2020-12-01 18:26:27 +00:00
Treehugger Robot
96cd149dfb Merge "Deprecated UserManager.getUsers(excludeDying) / added getAliveUsers()" am: c0b44fca8b am: 902918a433
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1406256

Change-Id: I44114ea2abcba197c8614c1e93db8b28faf16afe
2020-12-01 18:07:01 +00:00
Treehugger Robot
902918a433 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
Felipe Leme
ed14cda477 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 72eeb557e7)
2020-12-01 15:25:52 +08:00
Remi NGUYEN VAN
f5417ce9b6 Merge "Run OemNetworkPreferencesTest with DevSdkIgnoreRunner" am: 8384c693d1 am: 5bfbc47c2c am: 8a30831e98
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1512665

Change-Id: Id5562e4d66f50a0c2ee9d863982f38523c5602b7
2020-12-01 02:43:58 +00:00
Remi NGUYEN VAN
8a30831e98 Merge "Run OemNetworkPreferencesTest with DevSdkIgnoreRunner" am: 8384c693d1 am: 5bfbc47c2c
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1512665

Change-Id: I3583a9e7af5ffdc59ee1261f18944a52c82ab6ca
2020-12-01 02:13:50 +00:00
Remi NGUYEN VAN
5bfbc47c2c Merge "Run OemNetworkPreferencesTest with DevSdkIgnoreRunner" am: 8384c693d1
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
8384c693d1 Merge "Run OemNetworkPreferencesTest with DevSdkIgnoreRunner" 2020-12-01 01:33:42 +00:00
Lorenzo Colitti
c1e4f02f37 Merge changes If2201f39,Ia1c366c5 am: fd0e9821fb am: 95e7eba65a am: 8ff435aced
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1509889

Change-Id: Ic2857aae38dfa7ccf9996689e198f9e175045462
2020-11-30 15:59:20 +00:00
Lorenzo Colitti
8ff435aced Merge changes If2201f39,Ia1c366c5 am: fd0e9821fb am: 95e7eba65a
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1509889

Change-Id: I22a75b31abf5f0adfe2835f9da66344aa73a3a22
2020-11-30 15:18:19 +00:00
Lorenzo Colitti
c8f90ba551 Merge changes I982543cd,I41c3bf6c,Id3e5f6e1 am: 4fe79a3ff9 am: db7c229729 am: d5450e378b
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1511316

Change-Id: I91ccdc9a5f4426d9c1623b869c0411b9af203c36
2020-11-30 15:05:48 +00:00
Lorenzo Colitti
95e7eba65a Merge changes If2201f39,Ia1c366c5 am: fd0e9821fb
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
d5450e378b Merge changes I982543cd,I41c3bf6c,Id3e5f6e1 am: 4fe79a3ff9 am: db7c229729
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1511316

Change-Id: I780dbee953862c6c49200f32d74fad66607a7474
2020-11-30 14:28:05 +00:00
Lorenzo Colitti
fd0e9821fb 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
db7c229729 Merge changes I982543cd,I41c3bf6c,Id3e5f6e1 am: 4fe79a3ff9
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
4fe79a3ff9 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
Chalard Jean
8c7cb6449c Add a provider to VPN
Test: FrameworksNetTests NetworkStackTests
Change-Id: I982543cdee358bb62d3b56a7fd9d71dc18908b65
2020-11-30 16:15:19 +09:00
Chalard Jean
fd64bac5b6 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
Lucas Lin
23ebd21dba [automerger skipped] Merge "Ignore verifying canBeSatisfiedBy() on Android Q" into mainline-prod am: 3c56253229 -s ours
am skip reason: Change-Id Ibe317b56f82d3ea100b1d78c3907dce4f2fd964d with SHA-1 aa00183916 is in history

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13129586

Change-Id: Idee98c06845ea296d2bb88a946fb1677784a09d0
2020-11-30 06:38:35 +00:00
Treehugger Robot
eb2296e64d Merge "Adding @IgnoreUpTo to OemNetworkPreferencesTest" am: 9a9e45ad72 am: b32ead42ae am: ef777466b6
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1511772

Change-Id: Ib3782ba72d93d0fe647a6433dda4cdc51a645fb0
2020-11-30 02:55:00 +00:00
Treehugger Robot
ef777466b6 Merge "Adding @IgnoreUpTo to OemNetworkPreferencesTest" am: 9a9e45ad72 am: b32ead42ae
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1511772

Change-Id: I6d89952b92960388319c516858ffbc08fd69b058
2020-11-30 02:24:57 +00:00
Treehugger Robot
b32ead42ae Merge "Adding @IgnoreUpTo to OemNetworkPreferencesTest" am: 9a9e45ad72
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
535d328def 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
9a9e45ad72 Merge "Adding @IgnoreUpTo to OemNetworkPreferencesTest" 2020-11-30 01:38:19 +00:00
Lorenzo Colitti
25b66986ae Merge changes from topic "networkagent-set-underlying-networks" am: dccf7eda5e am: b428266cd1 am: d2e2a4a639
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1501816

Change-Id: I6a96b80ab6d94e0cfe4b202ec5aa4a3096c2f090
2020-11-28 04:51:20 +00:00
Lorenzo Colitti
a3ad45295d Clear calling identity in registerNetworkAgent. am: 4b1cd16a76 am: 964f7c7e4d am: 7c00b2f055
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1511317

Change-Id: I6aee037648415475a53053d1bcf015227cf8ec96
2020-11-28 04:51:10 +00:00
Lorenzo Colitti
7e32c1dd34 Allow tests to create TRANSPORT_TEST|TRANSPORT_VPN networks. am: 4b4fcc7a72 am: 04c831319e am: bb06c82637
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1511312

Change-Id: I631909b5db9507c7e62d498015c49d325d13f258
2020-11-28 04:51:03 +00:00
Lorenzo Colitti
3286928783 Move applying underlying caps from Vpn to ConnectivityService. am: 220987b38d am: a27c332849 am: ed3589c104
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1501815

Change-Id: I924998ffa45ba630d8688007878f339264e7108e
2020-11-28 04:50:46 +00:00
Lorenzo Colitti
d2e2a4a639 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
2020-11-28 04:09:19 +00:00
Lorenzo Colitti
7c00b2f055 Clear calling identity in registerNetworkAgent. am: 4b1cd16a76 am: 964f7c7e4d
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1511317

Change-Id: Ia731c724f32a52d609db513f07ac4615343ee0ad
2020-11-28 04:09:14 +00:00
Lorenzo Colitti
bb06c82637 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
2020-11-28 04:09:11 +00:00
Lorenzo Colitti
ed3589c104 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
2020-11-28 04:09:07 +00:00
Lorenzo Colitti
b428266cd1 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
964f7c7e4d Clear calling identity in registerNetworkAgent. am: 4b1cd16a76
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
04c831319e 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
2020-11-28 03:24:32 +00:00
Lorenzo Colitti
a27c332849 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
2020-11-28 03:20:40 +00:00
Lorenzo Colitti
aceffad3b2 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
db20f89e6d 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
4b1cd16a76 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
4b4fcc7a72 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
220987b38d 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
82f9a007c1 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
Lucas Lin
494c50af06 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.
Original-Change: https://android-review.googlesource.com/1508137
Merged-In: Ibe317b56f82d3ea100b1d78c3907dce4f2fd964d
Change-Id: Ibe317b56f82d3ea100b1d78c3907dce4f2fd964d
2020-11-26 07:34:54 +00:00
Treehugger Robot
6f3776b34a Merge changes Id4632e1b,I31985822,Ibbf96a25 am: b459e5166d am: 7814aeda39 am: 22c43689ce
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1511309

Change-Id: Ife8d852541eb8c96e9ada8d7037441514b7237bc
2020-11-26 05:33:56 +00:00
Treehugger Robot
22c43689ce Merge changes Id4632e1b,I31985822,Ibbf96a25 am: b459e5166d am: 7814aeda39
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1511309

Change-Id: I56294df5aa7773f9ed2caab4e14ed2a77b8f2a10
2020-11-26 05:11:03 +00:00
Treehugger Robot
7814aeda39 Merge changes Id4632e1b,I31985822,Ibbf96a25 am: b459e5166d
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
b459e5166d 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
c64d177ed9 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
621f5a9e8f 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
97ade70ce8 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