Commit Graph

1535 Commits

Author SHA1 Message Date
Remi NGUYEN VAN
2766d615e6 Merge "Revert "[VCN07] Bypass VCN for non-internet app accessible cellu..."" am: 75049d8ec8 am: 0ee35089b7 am: 96f21fd65f
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1585569

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I88648d8cab6081c178ecdd3b38935658a78b78dc
2021-02-16 02:23:51 +00:00
Lorenzo Colitti
9cdb79d634 Merge "BroadcastInterceptingContext: use passed-in broadcast Handler." am: b3ce8c39d8 am: 3d2c5d6774 am: 11eae148c4
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1589251

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I5d38e78800c9a524ae7ccf5d55ebae1a9f60922f
2021-02-15 12:08:03 +00:00
Remi NGUYEN VAN
75049d8ec8 Merge "Revert "[VCN07] Bypass VCN for non-internet app accessible cellu..."" 2021-02-15 11:39:25 +00:00
Lorenzo Colitti
37d17e60c3 BroadcastInterceptingContext: use passed-in broadcast Handler.
Currently, BroadcastInterceptingContext always runs broadcast
receivers on the thread that called sendBroadcast. This means:

1. Receivers might run on the wrong thread, making the test less
   realistic.
2. If any receiver checks what thread it's running on, then
   either the check needs to be modified or deleted, or the test
   must call sendBroadcast on the thread that the receiver
   expects to run on. The latter is impossible when there is more
   than one receiver that needs to run on more than one thread.

This CL adds a setUseRegisteredHandlers method that allows tests
to say that they want each receiver to run on the Handler
specified at registration time.

This CL also enables the new mode for ConnectivityServiceTest,
and resolves a TODO to re-enable a disabled thread check.

The new mode cannot be enabled by default because it would break
most of the tests.

All the below tests pass except for the car bluetooth test
testAutoConnectAdapterOff_returnsImmediately which was already failing.

Bug: 173331190
Test: atest CarInputServiceTest BluetoothProfileDeviceManagerTest
Test: atest NetworkPolicyManagerServiceTest
Test: atest ConnectivityServiceTest
Test: atest TetheringTest TetheringNotificationUpdaterTest
Test: atest VersionedBroadcastListenerTest EntitlementManagerTest
Test: atest TetheringConfigurationTest
Test: atest CachedDeviceStateServiceTest
Test: atest EmergencyAffordanceServiceTest
Change-Id: I3303bb14516f07a55d82a16b59c111ab3f8b0389
2021-02-15 10:40:32 +00:00
Lorenzo Colitti
f22aa33bc6 Merge changes Ia68f482a,I4911e214,Ied379654,I66d18512,Ie8e1bd63 am: 6e423b8024 am: f390bd61d7 am: 321e1c1f6a
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1581293

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I698b6b082b121c004b2c8b05ef423da1bd8b871b
2021-02-15 01:32:50 +00:00
Lorenzo Colitti
6e423b8024 Merge changes Ia68f482a,I4911e214,Ied379654,I66d18512,Ie8e1bd63
* changes:
  Check registering system default callback needs NETWORK_SETTINGS.
  Move VPN code from ConnectivityService to VpnManagerService.
  Add a skeleton VpnManagerService, and start it on boot.
  Convert LockdownVpnTracker to NetworkCallbacks.
  Minor fixes to VpnTransportInfo.
2021-02-15 00:00:47 +00:00
Yan Yan
3d818137f3 Merge changes Ifc8ad902,I6d1b8d0e am: 87c6253518 am: 66b74e588b am: 913569d3e5
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1453730

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I6f3235dd38e4c4912f986cbb27867ff14fe38e81
2021-02-12 22:46:32 +00:00
Remi NGUYEN VAN
54bb81ba9a Revert "[VCN07] Bypass VCN for non-internet app accessible cellu..."
Revert submission 1579872-vcn07

Reason for revert: Possible culprit for b/179768816, broken ConnectivityControllerTest
Reverted Changes:
Id09b19c13:Address comments on aosp/1550755
I245bd69e0:[VCN07.1] Add test for bypassing VCN for non-inter...
I9936894b9:[VCN07] Bypass VCN for non-internet app accessible...

Change-Id: Ie5f8c3051fed40623e5d4705ac2243ef51a898bd
2021-02-12 04:09:15 +00:00
Lorenzo Colitti
d5e9f98e28 Check registering system default callback needs NETWORK_SETTINGS.
Also address a code review comment.

Bug: 173331190
Test: test-only change
Change-Id: Ia68f482af6d10af203bdbd4e14a12ae0b12bb6b5
2021-02-12 01:12:48 +09:00
Lorenzo Colitti
0dd4b6f512 Move VPN code from ConnectivityService to VpnManagerService.
ConnectivityService itself does not depend on mVpns or the Vpn
class any more. Most of this CL is simply moving code from one
class to another:

- Move the AIDL calls from IConnectivityManager to IVpnManager.
- Move the implementation from ConnectivityService to
  the new VpnManagerService.
- Move the APIs from ConnectivityManager to VpnManager, but
  temporarily maintain some shims in ConnectivityManager for the
  moved calls so that existing callers do not have to be modified
  in this CL.
- Update VpnService to call IVpnManager instead of
  IConnectivityManager.
- Move the code that registers the VpnManager service from
  ConnectivityFrameworkInitializer to SystemServiceRegistry.

Bug: 173331190
Test: atest HostsideVpnTests FrameworksNetTests CtsNetTestCases
Change-Id: I4911e2144df721a94fa00da9edf0dc372a7091c2
2021-02-12 01:12:24 +09:00
Lorenzo Colitti
549e9acd92 Convert LockdownVpnTracker to NetworkCallbacks.
This will allow moving LockdownVpnTracker from the connectivity
to the VPN code. This requires moderate refactoring since it's
pretty tightly coupled to both.

In this CL:

1. Add an @hide API to tell ConnectivityService that legacy
   lockdown VPN is enabled. I chose not to use the existing
   setVpnRequiredForUids API because that method has specific
   semantics and because it will be required long term since
   it's used by non-legacy VPN types.

2. Instead of updating LockdownVpnTracker inline from the
   ConnectivityService handler thread, have it listen to
   NetworkCallbacks. This introduces an extra thread hop, but
   most of the interactions between the lockdown VPN and CS were
   via NetworkAgent, which is asynchronous anyway.

3. Add code to LegacyTypeTracker to send the extra
   CONNECTIVITY_ACTION broadcast for the underlying network type
   that is sent after the VPN connects. In order to do this, make
   Make LockdownVpnTracker specify its underlying network
   (via setUnderlyingNetworks) when it connects.

4. Reimplement LockdownVpnTracker#augmentNetworkInfo based on
   information that is available in ConnectivityService.

5. Remove the code in LockdownVpnTracker that counted errors.
   I think this code has not worked since lollipop, because
   ConnectivityService never sees NetworkInfo objects in state
   FAILED. This is because ConnectivityService only hears about
   NetworkInfo objects via NetworkAgents, and LegacyVpnRunner
   only registers its NetworkAgent when the connection succeeds.

Bug: 173331190
Test: passes existing tests in ConnectivityServiceTest
Change-Id: I66d18512882efd468ee0ecec61f28786a195b357
2021-02-12 01:07:29 +09:00
Lorenzo Colitti
720f3cc167 Minor fixes to VpnTransportInfo.
This CL addesses comments on aosp/1570921.

Bug: 173331190
Test: new test coverage
Change-Id: Ie8e1bd63bb818a03f4b17402e1b365577ca034a2
2021-02-11 23:28:00 +09:00
Yan Yan
00387a2654 Update underlying network of IpSecTunnelInterface
Bug: 169855650
Test: atest IpSecManagerTunnelTest
Change-Id: I6d1b8d0e49f89c67ddc2caf4ba63fb0b1eb062c0
2021-02-10 14:51:43 -08:00
Hai Shalom
f578bf4914 Merge "Support for Terms & Conditions notification" am: 67bb51ec40 am: fed30f42e8 am: b5a72aa56d
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1557451

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I0a47d12f41b9247910078ec8d6cd6e1f1589956e
2021-02-10 16:55:42 +00:00
Hai Shalom
67bb51ec40 Merge "Support for Terms & Conditions notification" 2021-02-10 15:36:58 +00:00
Lorenzo Colitti
6c9655f273 Merge changes from topics "vpnmove-getconnectionowneruid", "vpnmove-systemdefaultcallback", "vpnmove-vpntransportinfo" am: 5e21b83410 am: 5eac15c044 am: 22b1c63d51
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1572981

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I961b6442d53c1cb00af642866b7e49d151a9ab1e
2021-02-10 07:46:14 +00:00
Lorenzo Colitti
5e21b83410 Merge changes from topics "vpnmove-getconnectionowneruid", "vpnmove-systemdefaultcallback", "vpnmove-vpntransportinfo"
* changes:
  Stop using mVpns in getConnectionOwnerUid.
  Add a VpnTransportInfo object.
  Add a registerSystemDefaultNetworkCallback method.
2021-02-10 06:38:41 +00:00
Lorenzo Colitti
bd015f4861 Stop using mVpns in getConnectionOwnerUid.
Use data that is already available in ConnectivityService
instead.

The behaviour of the new implementation is slightly different
from Q and R code when the permission check fails.

- The old code would throw a SecurityException if an app that
  was not an active VPN called the method, and would return
  INVALID_UID if the connection belonged to a UID that was not
  subject to the VPN.
- The new code returns INVALID_UID in both cases.

This does not seem like a compatibility problem. The only case in
which the code throws SecurityException is if the app is not a
current VPN app, but the app already knows whether it is or not.
The docs don't mention that the method SecurityException, either.

Bug: 173331190
Test: atest FrameworksNetTests
Test: atest HostsideVpnTests
Change-Id: If3d031e74df33b5c97e12ebf02272faac6769d50
2021-02-10 02:52:16 +09:00
Lorenzo Colitti
523b5e8405 Add a VpnTransportInfo object.
This currently stores the VPN type and a session name, but can be
extended in the future.

Bug: 173331190
Test: added coverage in VpnTest
Test: added coverage in ConnectivityServiceTest
Test: added coverage in NetworkAgentTest
Change-Id: I450858a9fa332c8d896dbdb4c14337d5ec23677f
2021-02-10 02:52:16 +09:00
Lorenzo Colitti
80b48bc589 Add a registerSystemDefaultNetworkCallback method.
This method allows internal components to track the system
default network. This differs from registerDefaultNetworkCallback
because that method sends callbacks for the default network for
the UID that called it. This may not be the system default
network, for example, when a VPN is up and applies to the UID.

Bug: 173331190
Test: new unit tests in ConnectivityServiceTest
Test: new unit tests in ConnectivityManagerTest
Test: new CTS tests in ConnectivityServiceTest
Test: new CTS tests in HostsideVpnTests in other CL in this topic
Change-Id: Id02748a2183f71b71ff2a53a580466b9dcecaa93
2021-02-09 20:58:28 +09:00
Junyu Lai
6251da61be Merge changes from topic "removeNI" am: c60c7b4df8 am: c62d1e3b0c am: ecac1d2479
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1536707

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I3553ff41d85f44c481ea065e6cbda5d286f9e1fa
2021-02-09 05:49:15 +00:00
Junyu Lai
c60c7b4df8 Merge changes from topic "removeNI"
* changes:
  [FUI07] Stop making NetworkState with NetworkInfo from external callers
  [FUI06] Stop using NetworkInfo in NetworkState from external callers
2021-02-09 03:37:59 +00:00
Junyu Lai
db59cf7731 Merge "[VCN07] Bypass VCN for non-internet app accessible cellular services" am: f1d8c34877 am: f3e868f4d0 am: e9fe15bfe1
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1549817

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I915ba6692ebae6ae09429d515ef612fdd48590f8
2021-02-08 22:37:06 +00:00
Roshan Pius
8e9626ed47 Merge "ConnectivityService: Plumb attribution tag for location permission checks" am: 482b2dda4f am: cef5161a27 am: bd0120da19
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1534625

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I72340de13e04640935403d282a1d9f5afe0536e6
2021-02-08 21:40:29 +00:00
Junyu Lai
f1d8c34877 Merge "[VCN07] Bypass VCN for non-internet app accessible cellular services" 2021-02-08 21:40:09 +00:00
Hai Shalom
7fcd18ae0b Support for Terms & Conditions notification
- Added API to add T&C URL in the CaptivePortalData class, and to
indicate if the source is from Passpoint.
- Added source indication for the Venue URL API.
- Allow the connectivity service to send a new T&C acceptance
notification.
- Updated the merge method to prefer the Capport data over the
network agent data, if the source is not authenticated (not from
Passpoint).
- Propagate the Venue Friendly name to the captive portal activity
to be used instead of SSID, when available.

Bug: 162785447
Test: End-to-end test
Test: atest ConnectivityServiceTest
Test: atest CtsNetTestCasesLatestSdk:CaptivePortalDataTest
Test: atest NetworkNotificationManagerTest
Change-Id: I4e77c3b6c01941b03c46ad32da70c77e0fecac64
2021-02-08 12:05:20 -08:00
Roshan Pius
c97d806148 ConnectivityService: Plumb attribution tag for location permission checks
Not currently setting the atttribution tag for location
permission checks. Plumb the attribution tag for all location permision
checks (so that location access is correctly attributed to individual
components within an app)

Bug: 162602799
Test: atest android.net
Test: atest com.android.server
Change-Id: Iee95f05204f51a4f8cb1f36acfb60e8cdeb156f4
2021-02-08 08:13:48 -08:00
junyulai
aabc564902 [FUI07] Stop making NetworkState with NetworkInfo from external callers
Follow-up from previous patch. This change stop accessing the
constructor that needs NetworkInfo to create NetworkState, which
is no longer accessible after ConnectivityService become
mainline module. Instead, pass a legacy network type which is
dedicated for the need of the type.

Test: atest FrameworksNetTests NetworkPolicyManagerServiceTest
Bug: 174123988
Change-Id: I24157bc33e5a5819eccd6a3111d2049f531c1d43
2021-02-08 21:58:02 +08:00
Lorenzo Colitti
c55563a045 Merge changes I4256ca5f,I91528e1a,I48bd594c am: 82c60d022d am: afa74de47d am: 909af3ded7
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1579985

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I7201b62010a56962a16a89bb43cbde75cda22e14
2021-02-08 12:13:23 +00:00
Lorenzo Colitti
82c60d022d Merge changes I4256ca5f,I91528e1a,I48bd594c
* changes:
  Change ConnectivityServiceTest to prepare for VPN code move.
  Add to VpnManager the VPN APIs used by Settings and SystemUI.
  Remove temporary hack in VpnTest.
2021-02-08 10:41:32 +00:00
Treehugger Robot
41eda8d96a Merge "[VCN03] Linger the newly connected network for a short time" am: c5bd380f2b am: 733561ba51 am: d405f3a995
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1527820

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I048c81620a3ad4af481c43d27de10f92ca4fb18c
2021-02-08 05:59:15 +00:00
Treehugger Robot
c5bd380f2b Merge "[VCN03] Linger the newly connected network for a short time" 2021-02-08 04:57:35 +00:00
Lorenzo Colitti
852baaab79 Change ConnectivityServiceTest to prepare for VPN code move.
No-op changes to make it easier to review the VPN code move.
1. Set underlying networks via MockVpn, not ConnectivityService.
2. Add a processBroadcastForVpn utility method that we can modify
   without too much churn when the code is moved.

Bug: 173331190
Test: test-only change
Change-Id: I4256ca5f33034ef9d1de79857795a6ed1d644e61
2021-02-07 20:40:52 +09:00
Lorenzo Colitti
a6e7006967 Remove temporary hack in VpnTest.
This temporary hack was necessary due to b/175883995. Now that
that bug is fixed, remove the hack.

Bug: 171529940
Test: test-only change
Change-Id: I48bd594cf3a37575f4888c1be9a1cf535de2e4d2
2021-02-07 20:40:46 +09:00
junyulai
f6d98ec185 [VCN03] Linger the newly connected network for a short time
This is mainly used by VCN, where VCN-eligible networks might
be registered before VCN management service can fire request
to prevent the newly created network from being torndown
immediately by ConnectivityService.

Test: atest ConnectivityServiceTest#testNewNetworkLingering
      atest ConnectivityServiceTest#testNewNetworkLingering_bgNetwork
      atest FrameworksNetTests --rerun-until-failure 20
Bug: 175180558
Change-Id: I7768daf4cf2d8f6d8057b5107412e06104ba82e0
2021-02-06 11:22:31 +08:00
Aaron Huang
5b748de126 Merge "Update VpnTest for new restricted API" am: 20507cf1f9 am: 1fb754cc9c am: 4bec1c714d
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1554177

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I9188685fe0bb5ee7dfe2c0538fea6644b2cd642e
2021-02-05 12:50:16 +00:00
Aaron Huang
20507cf1f9 Merge "Update VpnTest for new restricted API" 2021-02-05 10:52:54 +00:00
Lorenzo Colitti
87ce7654bf Merge changes Ieb7f33bc,I81b56862 am: df7233f8e1 am: 92860eb233 am: 90cf1ed3f7
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1570920

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ie296e709b883fc2930b83dffbfb1366dd4a7e7e7
2021-02-05 09:55:17 +00:00
Paul Hu
0b756aeb45 Merge "Replace NPMI#isUidNetworkingBlocked()" am: 9113cf2872 am: c48b6bb362 am: b3cd3bb875
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1536313

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I53f5fb0996ad08c8a44c0560ab72725c47e39215
2021-02-05 08:15:29 +00:00
Lorenzo Colitti
df7233f8e1 Merge changes Ieb7f33bc,I81b56862
* changes:
  Fix the legacy VPN tests that start racoon.
  Make testLegacyLockdownVpn more realistic.
2021-02-05 07:34:43 +00:00
Paul Hu
9113cf2872 Merge "Replace NPMI#isUidNetworkingBlocked()" 2021-02-05 06:38:02 +00:00
Lorenzo Colitti
f5a4ac9592 Fix the legacy VPN tests that start racoon.
These tests do not actually work, or at least not as designed.
What happens when they are run is that creating/connecting the
VPN throws an exception. The call to legacyRunnerReady.block()
times out after 10 seconds because the condition variable is
never opened, but the doesn't notice the timeout becasue it
doesn't check the return value of block().

There are two reasons for the VPN not coming up.
1. VpnConfig.getIntentForStatusPanel calls into PendingIntent and
   ActivityManager statics, which bypass all the mocks and fail
   with an appops denial. Fix this by making it a dependency.
2. The tests are broken due to the UserManager API changes
   tracked in b/175883995. Fixing by adding a bit of ad-hoc code
   into startLegacyVpn, with a TODO to delete it once the rest of
   the UserManager setup code is fixed.

Fix these and check the return value of block(). This ensures
that if any other breakage is added the test will actually fail.
Also check that the throw route survives all the way to the
LinkProperties sent to the agent.

Bug: 173331190
Test: atest com.android.server.connectivity.VpnTest
Change-Id: Ieb7f33bce283ac5ee562a912df8edb9c930ed2b0
2021-02-05 14:40:13 +09:00
Lorenzo Colitti
3a2a0a31f4 Make testLegacyLockdownVpn more realistic.
Bug: 173331190
Test: test-only change
Change-Id: I81b5686244f479d967c826e29eba4feb396a09cf
2021-02-05 14:36:54 +09:00
paulhu
97114c99b4 Replace NPMI#isUidNetworkingBlocked()
ConnectivityService is going to become a mainline module which
will not able to access hidden APIs. NetworkPolicyManagerInternal
is a internal serivce that CS can't be access after be a mainline
module. Thus, create NPM#checkUidNetworkingBlocked to replace it.

Bug: 170598012
Test: atest FrameworksNetTests
Test: atest CtsNetTestCases
Test: atest CtsHostsideNetworkTests
Test: atest FrameworksCoreTests:NetworkPolicyManagerTest
Test: atest FrameworksServicesTests:NetworkPolicyManagerServiceTest
Change-Id: I7bee37522dc5c55c255b159fda9481eff663655a
2021-02-04 19:28:57 +08:00
Aaron Huang
a8a74f1988 Update VpnTest for new restricted API
This patch addressses the mocked UserManager for the context
of the user which is created by createContextAsUser.

Bug: 171529940
Bug: 175883995
Test: FrameworksNetTests
Change-Id: Ie72d08c765ed7fb7083c0c4b7ee02a43c23d1707
2021-02-04 19:14:57 +08:00
Treehugger Robot
a9c77e909e Merge "Revert the fallback naming into default network" am: 068b629dfe am: 74126b9bb0 am: 4e42931c64
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1574083

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I697cbceff12a2cdc2aa7c36bcfbf4ea28f68ab82
2021-02-04 10:12:01 +00:00
Lorenzo Colitti
02e6ba7210 Merge "Improve getConnectionOwnerUid tests." am: bd2f639a30 am: aa7644c9f9 am: 42f099f5c2
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1572980

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ie69cc409c24468aaebb4a0267009bdc4f9b7a622
2021-02-04 10:11:21 +00:00
junyulai
1243a00669 [VCN07] Bypass VCN for non-internet app accessible cellular services
Deduce the NET_CAPABILITY_NOT_VCN_MANAGED capability from other
capabilities and user intention, which includes:
   1. For the requests that don't have anything besides
      VCN_SUPPORTED_CAPABILITIES, add the NOT_VCN_MANAGED to
      allow the callers automatically utilize VCN networks
      if available.
   2. For the requests that explicitly add or remove
      NOT_VCN_MANAGED,  do not alter them to allow user fire
      request that suits their need.

Test: atest NetworkRequestTest#testBypassingVcnForNonInternetRequest
Bug: 175662146
Change-Id: I9936894b9530a22fb186cfd25cbee0fced65b72b
2021-02-04 17:07:23 +08:00
Treehugger Robot
068b629dfe Merge "Revert the fallback naming into default network" 2021-02-04 08:48:21 +00:00
Lorenzo Colitti
dbcd5d632a Improve getConnectionOwnerUid tests.
Currently, the tests only check whether the method throws a
SecurityException or not. Also check the return value of the
call, by mocking out InetDiagMessage.getConnectionOwnerUid.

This is required to test an upcoming change that will never
throw SecurityException but always return INVALID_UID if the
caller lacks permissions.

Bug: 173331190
Test: test-only change
Change-Id: I63f42a2f098fcf8796c9b4525a3a7b8320c0a139
2021-02-04 04:19:28 +00:00