Commit Graph

2218 Commits

Author SHA1 Message Date
Paul Hu
91c64b9b11 Merge "Address leftover comments" am: 6e253df579 am: 3b29da5cf7 am: 3bd18cce4a
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1495899

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I3f46b0c6d5c2dcce540fcb1f9d7f2cc22c934f93
2020-12-11 10:51:37 +00:00
Paul Hu
6e253df579 Merge "Address leftover comments" 2020-12-10 15:47:27 +00:00
Paul Hu
9a0d7d2933 Merge "Revert "ConnectivityServiceTest: Mark unaudited PendingIntents with FLAG_MUTABLE_UNAUDITED"" 2020-12-10 12:27:07 +00:00
Lorenzo Colitti
358aeea9d3 Merge changes I6eb6d92b,I638e29fd,I2348b7a3 am: 0da448710c am: 3ff54c739f am: 5bbcd79710
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1521657

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I430d7069e1dfbe89780cb459fff9e1eb63daa349
2020-12-10 09:18:35 +00:00
Lorenzo Colitti
0da448710c 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.
2020-12-10 08:11:52 +00:00
Remi NGUYEN VAN
11119f7461 Revert "ConnectivityServiceTest: Mark unaudited PendingIntents with FLAG_MUTABLE_UNAUDITED"
This reverts commit 7d6a49c959.

Reason for revert: Merge conflicts, should have been merged in AOSP

Change-Id: Iee0a3e76c42858bcca45517e3ca02c65bc8eac0c
2020-12-10 04:42:06 +00:00
Serik Beketayev
8a826845a3 Merge "[Mainline Migration] Migrate NetworkUtils" am: 8339b3ded3 am: 59f81edbdb am: 402f439ac1
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1498168

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Id0749108e03d88af0b8c50a36f1a4ca28b9a40ce
2020-12-10 01:05:32 +00:00
Serik Beketayev
8339b3ded3 Merge "[Mainline Migration] Migrate NetworkUtils" 2020-12-09 23:47:05 +00:00
Lorenzo Colitti
39b4c5b2da Disallow NetworkAgents from changing the owner UID.
The current behaviour with regards to changing the owner UID is
bizarre and arguably incorrect. A NetworkAgent can change the
owner to whatever other app it wants, regardless of signatures,
at any time. This includes, for example, transferring ownership
to another UID and then recovering it.

Fortunately no existing NetworkAgent appears to do this:
- ClientModeImpl sets it to the UID of the app that created the
  configuration. It doesn't look like it can change while the
  network is connected.
- Vpn sets it to the UID of the VPN owner. That also can't change.
- Telephony does not appear to set it at all, it only sets the
  administrator UIDs (and updates them whenever it gets
  EVENT_CARRIER_PRIVILEGED_UIDS_CHANGED).

Disallow this now before code is written that depends on it.

Bug: 175188445
Test: modified tests in ConnectivityServiceTest
Change-Id: I638e29fda2481ec3bf4fff562ea66a73322881df
2020-12-09 19:47:17 +09:00
Lorenzo Colitti
cb9bbf2c80 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
2020-12-09 19:33:32 +09:00
Lorenzo Colitti
4eb55bc947 Merge "Test for the current behaviour of updating a network's owner UID." am: aafcaa9fb5 am: 62976a3a26 am: 8e44d9d778
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1512690

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ic97c893a17dcf7ce18fe31ff05828d4fe9a5e929
2020-12-08 11:02:46 +00:00
Lorenzo Colitti
aafcaa9fb5 Merge "Test for the current behaviour of updating a network's owner UID." 2020-12-08 09:10:08 +00:00
Lorenzo Colitti
d1bff1fafd Merge "Add a test for TcpKeepalivePacketDataParcelable.toString()." am: ee3c193706 am: 4f4ac4840d am: 964daa1a04
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1502382

Change-Id: Ib3cf8cfb3f658e119d6c725653fcfaa385766b1f
2020-12-07 21:00:25 +00:00
Ashwini Oruganti
cc1039b7c7 Merge "ConnectivityServiceTest: Mark unaudited PendingIntents with FLAG_MUTABLE_UNAUDITED" 2020-12-07 19:41:50 +00:00
Lorenzo Colitti
76a1031d33 Test for the current behaviour of updating a network's owner UID.
The current behaviour is at least bizarre and arguably incorrect.
Add a test to document the current behaviour so we can check that
any changes we make to this behaviour are correct.

Test: test-only change
Change-Id: I345bd320eced96316d92e520f576ae06b8020d9f
2020-12-08 01:40:47 +09:00
Serik Beketayev
88bf984e07 [Mainline Migration] Migrate NetworkUtils
Migrating makeStrings(), numericToInetAddress() APIs

Bug: 173089079
Test: atest FrameworksNetTests
Change-Id: Ie914fd41bc3ce16d07f5d2768b89ce805b9245a9
2020-12-06 22:33:04 -08:00
Lorenzo Colitti
ee3c193706 Merge "Add a test for TcpKeepalivePacketDataParcelable.toString()." 2020-12-07 04:38:53 +00:00
Patrick Rohr
bbef873e3e Merge changes from topic "restricted-networking-mode" am: 1d156cb04e am: 83711b9a0b am: 5fda0bd0af
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1505234

Change-Id: Ia175efd2e152ea4b04feddf3bdc159adca2edab5
2020-12-03 12:39:44 +00:00
Patrick Rohr
66978d1090 Clean Up NetworkManagementService Tests am: e7c4a3e7b5 am: 34d43318e1 am: 9653c209c6
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1505233

Change-Id: I24c7401ae08da82ad8e03db1b507abe50e92dd1b
2020-12-03 12:39:27 +00:00
Patrick Rohr
34d43318e1 Clean Up NetworkManagementService Tests am: e7c4a3e7b5
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1505233

Change-Id: Ia14b1784f36d54f0ba73d5841afedcf8a55a18f2
2020-12-03 11:36:15 +00:00
Patrick Rohr
1d156cb04e Merge changes from topic "restricted-networking-mode"
* changes:
  Add Restricted Mode Firewall Chain
  Clean Up NetworkManagementService Tests
2020-12-03 10:50:25 +00:00
Remi NGUYEN VAN
f6271f533e Merge "Do not query CS in NetworkProvider constructor" am: 6a6e5f8479 am: 0d1b3960e8 am: bcd4d930bc
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1512873

Change-Id: I194f6fed28011702dd86676e5aa422129a903d9c
2020-12-03 03:47:02 +00:00
Remi NGUYEN VAN
6a6e5f8479 Merge "Do not query CS in NetworkProvider constructor" 2020-12-03 01:48:01 +00:00
Lorenzo Colitti
d58b4ea78c Merge changes Ic5a3e169,I76daa3ab am: fac6ce5e4d am: 642fe3bb2b am: 4a0fe09eec
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1512888

Change-Id: If54ea6526d4426e6e52eec40c72f3ddd625842fe
2020-12-02 06:42:39 +00:00
Lorenzo Colitti
fac6ce5e4d Merge changes Ic5a3e169,I76daa3ab
* changes:
  Refactor applyUnderlyingCapabilities and its test.
  Move applyUnderlyingCapabilities to ConnectivityService.
2020-12-02 04:55:12 +00:00
Lorenzo Colitti
8750be0016 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
Lorenzo Colitti
cd6d42bd1e 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
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
8384c693d1 Merge "Run OemNetworkPreferencesTest with DevSdkIgnoreRunner" 2020-12-01 01:33:42 +00:00
Patrick Rohr
7146229936 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
e7c4a3e7b5 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
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
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
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
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
Remi NGUYEN VAN
7820e22137 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
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
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
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
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
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
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
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