Commit Graph

1376 Commits

Author SHA1 Message Date
Lorenzo Colitti
50c30ed67f Merge "Generalize support for underlying networks." am: ca830d9239 am: 51c973d4b7 am: 2be66008a0
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1513052

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ida4e4d7b6d607d6c9f6efc2d06732f7826f7942e
2020-12-14 06:40:27 +00:00
Treehugger Robot
1e7b9bca3d Merge "Fix a crash in eng builds" am: 26d146ff7f am: 99890b486d am: f65b271328
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1527538

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I6e1c20b4c1004e8205d65f318939ee7d8b006f00
2020-12-14 06:39:50 +00:00
Lorenzo Colitti
ca830d9239 Merge "Generalize support for underlying networks." 2020-12-14 05:19:49 +00:00
Treehugger Robot
26d146ff7f Merge "Fix a crash in eng builds" 2020-12-14 05:17:15 +00:00
Chiachang Wang
83e35e70c4 Merge "Resolve UidRange dependency between NMS and CS module" am: c5be33af21 am: 8a3181b166 am: 2ec8e8071a
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1495869

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I6c3474e6522fc67aec5333b323768692619019ee
2020-12-14 04:23:43 +00:00
Chiachang Wang
c5be33af21 Merge "Resolve UidRange dependency between NMS and CS module" 2020-12-14 02:55:41 +00:00
Chalard Jean
8fb84150bf Fix a crash in eng builds
CAPTIVE_PORTAL is a CS-managed capability, and causes CS to log a wtf.
When this test is run on an eng build, this sends SIGSEGV to the test,
which is pretty difficult to debug.

Test: FrameworksNetTests NetworkStackTests
Change-Id: I72fc46a6daa4e886425b4dc967318cca9f1a5302
2020-12-13 23:02:08 +09:00
Lorenzo Colitti
01d3763c5e Generalize support for underlying networks.
Currently, ConnectivityService assumes that only VPNs can have
underlying networks. Make the code decide this based only on the
return value of NetworkAgentInfo#supportsUnderlyingNetworks.
This allows non-VPN network types to support underlying networks
in the future.

This requires storing the original agent's capabilities in
NetworkAgentInfo so that applyUnderlyingCapabilities can mix in
the underlying network capabilities without overwriting the
capabilities of the network itself. Currently, the only
information that applyUnderlyingCapabilities takes from the
original agent's capabilities are the metered bit (stored in
NetworkAgentInfo#declaredMetered) and the transports (assumed to
be exactly {TRANSPORT_VPN}. Store the full capabilities instead.
This is more state than needed but it ensures that we do not need
to make any changes if in the future we want to propagate new
types of information from the underlying networks.

This should have no impact on current use cases (i.e., VPNs).

There is a change in ordering: in disconnectAndDestroyNetwork,
the new code propagates underlying network capabilities before
removing the network from LegacyTypeTracker, instead of after.

This is done to simplify the new code. When the new code
propagates underlying network capabilities in response to a
change for a particular network (e.g., connect, disconnect,
capabilities change), it only considers networks that have the
changed network as underlying. Because determining the
underlying networks requires knowing the default network,
the new code runs before the default network is changed and
LegacyTypeTracker is updated.

This shouldn't have app implications because the connectivity
broadcasts sent by LegacyTypeTracker and the callbacks cannot be
ordered, since they run on separate threads with unpredictable
delays. The capability change callbacks resulting from
propagation of underlying network capabilities were already
sent before the rematch, so the callbacks themselves are not
reordered in any way.

Bug: 173331190
Test: atest FrameworksNetTests \
            CtsNetTestCases:NetworkAgentTest \
	    CtsNetTestCases:Ikev2VpnTest \
	    CtsNetTestCases:VpnServiceTest \
	    CtsNetTestCases:android.net.cts.ConnectivityDiagnosticsManagerTest \
	    HostsideVpnTests com.android.server.connectivity.VpnTest
Change-Id: Ic5353a928a3a3541dcf953c35f47277c5e295db8
2020-12-13 00:10:56 +09:00
Chalard Jean
d2c548d880 Merge changes from topic "remove_legacy_NA" am: 71ab824707 am: a698a47ada am: 7ba18da6b6
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1456097

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: If9cd6ce929a7103d2d6b7195a71ee64ea0a4ee0a
2020-12-11 11:03:36 +00:00
Lucas Lin
1061b76b27 Merge "Use getUserHandles() instead of getUsers() to get user id" am: df93f1c06c am: 7936252059 am: 865683a998
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1513050

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I7fa8802614bf28453501cdc2bc1989b3531b2280
2020-12-11 11:02:48 +00:00
Treehugger Robot
b7f07a5371 Merge "Add a mutability flag to the PendingIntent" am: e5046ca23b am: 590c8766b6 am: a97a84a6cf
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1505734

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I2d71235f8a61e617f95094da1154342c00e9b8d5
2020-12-11 10:53:02 +00:00
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
Chalard Jean
71ab824707 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
2020-12-11 02:32:57 +00:00
Lucas Lin
df93f1c06c Merge "Use getUserHandles() instead of getUsers() to get user id" 2020-12-11 02:02:37 +00:00
Treehugger Robot
e5046ca23b Merge "Add a mutability flag to the PendingIntent" 2020-12-10 16:27:58 +00:00
Paul Hu
6e253df579 Merge "Address leftover comments" 2020-12-10 15:47:27 +00:00
Chiachang Wang
1f50ae5c28 Resolve UidRange dependency between NMS and CS module
ConnectivityService is going to become a mainline module which
cannot access hidden APIs. Thus, replace the VPN uid range
controlling APIs from NMS to INetd directly.

Bug: 170598012
Test: atest FrameworksNetTests
Test: atest HostsideVpnTests
Test: manually test to connect to VPN and check the uid range
Change-Id: Ie6656ef36f54c2f14d5a2899e763a29b70a30f5d
2020-12-10 22:24:47 +08:00
paulhu
58333ae5bf Add a mutability flag to the PendingIntent
From S, it's required to specify explicitly either FLAG_MUTABLE
or FLAG_IMMUTABLE when creating a PendingIntent. Thus, add a
mutability flag to the PendingIntent in ConnectivityServiceTest
that doesn't specify it before.

Bug: 173157160
Test: atest FrameworksNetTests
Change-Id: I755c53b90d709dfbac576dc076722476c3edee35
2020-12-10 12:28:14 +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
lucaslin
907cb16762 Use getUserHandles() instead of getUsers() to get user id
UserManager#getUsers() is a hidden API, use getUserHandles() to
get user id instead in PermissionMonitor.

Bug: 171529940
Test: atest FrameworksNetTests
Change-Id: Ic304627688de8e49505a95ebc99628b2e0eafab9
2020-12-10 13:58:39 +08: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
Chalard Jean
b274feac5c Migrate NetworkAgentWrapper to the new NA API
Test: FrameworksNetTests NetworkStackTests
Bug: 167544279
Change-Id: I5d53a938572682dea827ea681596226b1e271aa6
2020-12-08 19:43:10 +09: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
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
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
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
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
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
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