Commit graph android_packages_modules_Co.../tests/net/java
Message SHA1
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

Paul Hu   authored and   Automerger Merge Worker   commited 2020-12-11 10:51:37 +00:00
91c64b9b11
Merge "Address leftover comments"
Paul Hu   authored and   Gerrit Code Review   commited 2020-12-10 15:47:27 +00:00
6e253df579
Merge "Revert "ConnectivityServiceTest: Mark unaudited PendingIntents with FLAG_MUTABLE_UNAUDITED""
Paul Hu   authored and   Android (Google) Code Review   commited 2020-12-10 12:27:07 +00:00
9a0d7d2933
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

Lorenzo Colitti   authored and   Automerger Merge Worker   commited 2020-12-10 09:18:35 +00:00
358aeea9d3
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.

Lorenzo Colitti   authored and   Gerrit Code Review   commited 2020-12-10 08:11:52 +00:00
0da448710c
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

Remi NGUYEN VAN   commited 2020-12-10 04:42:06 +00:00
11119f7461
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

Serik Beketayev   authored and   Automerger Merge Worker   commited 2020-12-10 01:05:32 +00:00
8a826845a3
Merge "[Mainline Migration] Migrate NetworkUtils"
Serik Beketayev   authored and   Gerrit Code Review   commited 2020-12-09 23:47:05 +00:00
8339b3ded3
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

Lorenzo Colitti   commited 2020-12-09 19:47:17 +09:00
39b4c5b2da
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

Lorenzo Colitti   commited 2020-12-09 19:33:32 +09:00
cb9bbf2c80
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

Lorenzo Colitti   authored and   Automerger Merge Worker   commited 2020-12-08 11:02:46 +00:00
4eb55bc947
Merge "Test for the current behaviour of updating a network's owner UID."
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2020-12-08 09:10:08 +00:00
aafcaa9fb5
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

Lorenzo Colitti   authored and   Automerger Merge Worker   commited 2020-12-07 21:00:25 +00:00
d1bff1fafd
Merge "ConnectivityServiceTest: Mark unaudited PendingIntents with FLAG_MUTABLE_UNAUDITED"
Ashwini Oruganti   authored and   Android (Google) Code Review   commited 2020-12-07 19:41:50 +00:00
cc1039b7c7
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

Lorenzo Colitti   commited 2020-12-08 01:40:47 +09:00
76a1031d33
[Mainline Migration] Migrate NetworkUtils
Migrating makeStrings(), numericToInetAddress() APIs

Bug: 173089079
Test: atest FrameworksNetTests
Change-Id: Ie914fd41bc3ce16d07f5d2768b89ce805b9245a9

Serik Beketayev   commited 2020-12-06 22:33:04 -08:00
88bf984e07
Merge "Add a test for TcpKeepalivePacketDataParcelable.toString()."
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2020-12-07 04:38:53 +00:00
ee3c193706
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

Patrick Rohr   authored and   Automerger Merge Worker   commited 2020-12-03 12:39:44 +00:00
bbef873e3e
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

Patrick Rohr   authored and   Automerger Merge Worker   commited 2020-12-03 12:39:27 +00:00
66978d1090
Clean Up NetworkManagementService Tests am: e7c4a3e7b5
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1505233

Change-Id: Ia14b1784f36d54f0ba73d5841afedcf8a55a18f2

Patrick Rohr   authored and   Automerger Merge Worker   commited 2020-12-03 11:36:15 +00:00
34d43318e1
Merge changes from topic "restricted-networking-mode"
* changes:
  Add Restricted Mode Firewall Chain
  Clean Up NetworkManagementService Tests

Patrick Rohr   authored and   Gerrit Code Review   commited 2020-12-03 10:50:25 +00:00
1d156cb04e
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

Lorenzo Colitti   authored and   Automerger Merge Worker   commited 2020-12-02 06:42:39 +00:00
d58b4ea78c
Merge changes Ic5a3e169,I76daa3ab
* changes:
  Refactor applyUnderlyingCapabilities and its test.
  Move applyUnderlyingCapabilities to ConnectivityService.

Lorenzo Colitti   authored and   Gerrit Code Review   commited 2020-12-02 04:55:12 +00:00
fac6ce5e4d
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

Lorenzo Colitti   commited 2020-12-02 00:45:57 +09:00
8750be0016
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

Lorenzo Colitti   commited 2020-12-01 23:23:47 +09:00
cd6d42bd1e
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)

Felipe Leme   authored and   lucaslin   commited 2020-12-01 15:25:52 +08:00
ed14cda477
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

Patrick Rohr   commited 2020-11-30 18:36:02 +01:00
7146229936
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

Patrick Rohr   commited 2020-11-30 18:35:44 +01:00
e7c4a3e7b5
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

Lorenzo Colitti   authored and   Automerger Merge Worker   commited 2020-11-30 15:59:20 +00:00
c1e4f02f37
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

Lorenzo Colitti   authored and   Automerger Merge Worker   commited 2020-11-30 15:05:48 +00:00
c8f90ba551
Merge changes If2201f39,Ia1c366c5
* changes:
  Stop calling Vpn#updateCapabilities in CS.
  Stop accessing VPNs in checkConnectivityDiagnosticsPermissions.

Lorenzo Colitti   authored and   Gerrit Code Review   commited 2020-11-30 14:14:38 +00:00
fd0e9821fb
Add a provider to VPN
Test: FrameworksNetTests NetworkStackTests
Change-Id: I982543cdee358bb62d3b56a7fd9d71dc18908b65

Chalard Jean   commited 2020-11-30 16:15:19 +09:00
8c7cb6449c
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
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

Lorenzo Colitti   authored and   Automerger Merge Worker   commited 2020-11-28 04:50:46 +00:00
3286928783
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
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 am: 22c43689ce
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1511309

Change-Id: Ife8d852541eb8c96e9ada8d7037441514b7237bc

Treehugger Robot   authored and   Automerger Merge Worker   commited 2020-11-26 05:33:56 +00:00
6f3776b34a
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
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
ConnectivityServiceTest: Mark unaudited PendingIntents with FLAG_MUTABLE_UNAUDITED
These PIs need an explicit mutability flag. This temporay flag is being
used to mark these points in code and should be replaced ASAP.
See go/immutable-pendingintents for more context.

Bug: 160794467
Test: TH
Exempt-From-Owner-Approval: noop change
Change-Id: I963d0d737ecbd8ad07577f2fe93ba178419e7a5e

Ashwini Oruganti   commited 2020-11-23 21:56:35 +00:00
7d6a49c959
Merge changes Ibed6cdd4,I51e3c00d,Ibf37f94b am: 6e4b94388a am: d7bc7d7e29 am: 0905ca74db
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1498660

Change-Id: I68386af717aa15099a09f45b57d945f352396f3b

James Mattis   authored and   Automerger Merge Worker   commited 2020-11-21 02:04:15 +00:00
231417f27c
Update requestsSortedById() to sort by collection
Update requestsSortedById() to sort NetworkRequestInfo by their
nested collection of NetworkRequest objects vs a single request.
Before the NetworkRequestInfo with the request with the lowest
requestId would be sorted to the top. Now the NetworkRequestInfo
which contains the request with the lowest requestId will be
sorted to the top.

Bug: 173292541
Bug: 171991028
Test: atest FrameworksNetTests
Change-Id: I51e3c00d59443e37ddbf168c423d13df8d14fa64

James Mattis   commited 2020-11-19 17:04:02 -08:00
f8eb49ab6b
Merge "Make MockVpn more realistic and easier to use." am: 0dd10f43c7 am: c927d555cd am: 49156dc401 am: d591886ab8
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1501814

Change-Id: I1beca5148b05724042e3c2415015f2ffa3ed2be5

Lorenzo Colitti   authored and   Automerger Merge Worker   commited 2020-11-19 12:31:03 +00:00
cecb2bfcf4
Merge changes I3711b362,I49421183,Icc0701cb,I2f5ccc1d am: 40b4ef6dd7 am: 49038a76c2 am: 3968347b84 am: 3dea488951
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1501951

Change-Id: I5c7847bac88b574737ab80e5a20e9e22afb5b2e4

Lorenzo Colitti   authored and   Automerger Merge Worker   commited 2020-11-19 12:30:34 +00:00
7992b7baa6
Merge "Make MockVpn more realistic and easier to use."
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2020-11-19 10:32:19 +00:00
0dd10f43c7
Merge changes I3711b362,I49421183,Icc0701cb,I2f5ccc1d
* changes:
  Increase test coverage for VPN info sent to NetworkStatsService.
  Simplify MockVpn.
  Test a VPN with an underlying network that does not yet exist.
  Minor fixes to NetworkCapabilities#toString.

Lorenzo Colitti   authored and   Gerrit Code Review   commited 2020-11-19 10:20:00 +00:00
40b4ef6dd7