Commit graph

11,732 commits

Message SHA1
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

Roshan Pius   commited 2021-02-08 08:13:48 -08:00
aa24fdeb5d
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.

Lorenzo Colitti   authored and   Gerrit Code Review   commited 2021-02-08 10:41:32 +00:00
c4e50c9c50
Merge "Move shared Proxy method and constants to shared lib"
Chiachang Wang   authored and   Gerrit Code Review   commited 2021-02-08 10:27:05 +00:00
bf911c0f3c
Move shared Proxy method and constants to shared lib
The static validate() method an PROXY_* constants in Proxy are
used by both module and Settings. After Proxy is moving into
connectivity module, Setting will not able to access them.
Thus, move them to ProxyUtils in net shared lib.

Bug: 172183305
Test: atest FrameworksNetTests
Test: atest CtsNetTestCases:ProxyInfoTest
Change-Id: I02c88aeaeb53d62b87a42a2d8ead9b140b054650

Chiachang Wang   commited 2021-02-08 10:25:07 +00:00
ab9f017af4
Merge "[VCN03] Linger the newly connected network for a short time"
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-02-08 04:57:35 +00:00
819f6638a8
Merge "Create new system API in UserHandle to get uid"
Chiachang Wang   authored and   Gerrit Code Review   commited 2021-02-08 03:56:39 +00:00
e0a1006f6c
Merge "More cleanly separate requests and listens."
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2021-02-07 18:04:50 +00:00
660e3f4b29
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

Lorenzo Colitti   commited 2021-02-07 20:40:52 +09:00
af17de03ce
Add to VpnManager the VPN APIs used by Settings and SystemUI.
Settings and SystemUI use these through raw AIDL calls.
Make them proper manager calls so we can move the implementation
without touching the callers again.

For now these still call into ConnectivityService via
IConnectivityManager. In an upcoming CL the implementation will
move to VpnManagerService.

Test: m
Bug: 173331190
Change-Id: I91528e1ad9948fbaa1fc5e37c61c5eb95f54964e

Lorenzo Colitti   commited 2021-02-07 20:40:51 +09:00
f80ad439dd
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

Lorenzo Colitti   commited 2021-02-07 20:40:46 +09:00
e9192a51f4
More cleanly separate requests and listens.
Currently, NetworkRequest has several types of requests (LISTEN,
TRACK_DEFAULT, REQUEST, BACKGROUND_REQUEST), and we expect more
to be added.

There are really three categories of request:
1. Requests satisfied by only one network and will keep that
   network up, and thus need to be sent to NetworkProviders:
   REQUEST, BACKGROUND_REQUEST.
2. Requests satisfied by only one network but will not keep that
   network up: TRACK_DEFAULT
3. Requests satisfied by multiple networks and will not keep any
   networks up: LISTEN.

Unfortunately the separation is not very clear. Currently, for
any valid request, either isListen() will return true or
isRequest() will return true. This makes it impossible to tell
whether a particular request should be sent to NetworkProviders,
so the current code sends TRACK_DEFAULT requests to
NetworkProviders as well. This is incorrect - a TRACK_DEFAULT
should never keep a network up, for example.

This CL attempts to clarify things by making isRequest() return
false for TRACK_DEFAULT requests and thus never sending them to
NetworkProviders. After this CL:

- isRequest will return true only for requests that attempt to
  bring up or keep up a network.
- isListen will return true only for requests that match multiple
  networks but do not keep any of them up.
- Neither will return true for TRACK_DEFAULT.

Test: atest ConnectivityServiceTest
Change-Id: I7aad30ade8f7ab2a179e53483d9afd8675f64a12

Lorenzo Colitti   commited 2021-02-07 18:20:59 +09:00
96742d9695
Merge "Revert "[Mainline] Migrate android.utils package items""
Serik Beketayev   authored and   Gerrit Code Review   commited 2021-02-07 03:11:47 +00:00
7370eb56b6
Revert "[Mainline] Migrate android.utils package items"
Revert submission 1553146-android_util

Reason for revert: Build Breakage aosp-master/db845c-userdebug @ 7128996
Reverted Changes:
Ia39f6e03f:[Mainline] Migrate android.utils package items
Iaf99140d6:[Mainline] Migrate android.utils package items

Change-Id: I5bdaec5d1a87436510c3e05fadaf0124d86b1bdf

Serik Beketayev   commited 2021-02-06 09:19:47 +00:00
47c4d4d91e
Merge "[Mainline] Migrate android.utils package items"
Serik Beketayev   authored and   Gerrit Code Review   commited 2021-02-06 07:00:12 +00:00
d41acb6e75
Merge changes Iabad7300,I85363e28
* changes:
  Stubbed setOemNetworkPreference in Connectivity
  Update OemNetworkPreferences to use 1:1 Map

James Mattis   authored and   Gerrit Code Review   commited 2021-02-06 04:33:51 +00:00
d15312ef50
Merge "[Mainline] Core Platform APIs migration"
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-02-06 04:11:00 +00:00
1b9888440e
[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

junyulai   commited 2021-02-06 11:22:31 +08:00
0ac374f7bd
Merge "Update VpnTest for new restricted API"
Aaron Huang   authored and   Gerrit Code Review   commited 2021-02-05 10:52:54 +00:00
ca0b4f05f3
Merge "Add @Nullable to Object#equals()"
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-02-05 09:36:41 +00:00
25def597ea
Merge "[VCN09] Rename linger timer"
Junyu Lai   authored and   Gerrit Code Review   commited 2021-02-05 09:29:12 +00:00
3d3ceb1985
Merge "Remove legacy network factories"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2021-02-05 08:23:19 +00:00
db50390d54
[VCN09] Rename linger timer
Linger timer mechanism will be used for both "linger" and
"nascent" states. To prevent confusion, rename the linger
timer and related functions to more generic name.

Test: TH
Bug: 175180558
Change-Id: I652f7c65c2f8bc58fb9d3316480f23a9709eccce

junyulai   commited 2021-02-05 15:57:07 +08:00
2b6f0c2d71
Merge changes Ieb7f33bc,I81b56862
* changes:
  Fix the legacy VPN tests that start racoon.
  Make testLegacyLockdownVpn more realistic.

Lorenzo Colitti   authored and   Gerrit Code Review   commited 2021-02-05 07:34:43 +00:00
01a483ceec
Add @Nullable to Object#equals()
This is a partial cherry-pick of change:
I5eedb571c9d78862115dfdc5dae1cf2a35343580

for connectivity classes.

Bug: 170883422
Test: m
Merged-In: I5eedb571c9d78862115dfdc5dae1cf2a35343580
Change-Id: I7dc661863b73f4198ddb4f3a1566583d0f07db3c

Roman Kalukiewicz   authored and   Remi NGUYEN VAN   commited 2021-02-05 07:28:44 +00:00
384a8c63f2
Merge "Replace NPMI#isUidNetworkingBlocked()"
Paul Hu   authored and   Gerrit Code Review   commited 2021-02-05 06:38:02 +00:00
f5f52850f2
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

Lorenzo Colitti   commited 2021-02-05 14:40:13 +09:00
dd53c5889b
Make testLegacyLockdownVpn more realistic.
Bug: 173331190
Test: test-only change
Change-Id: I81b5686244f479d967c826e29eba4feb396a09cf

Lorenzo Colitti   commited 2021-02-05 14:36:54 +09:00
6d9fd406d4
Stubbed setOemNetworkPreference in Connectivity
Stubbed setOemNetworkPreference() in ConnectivityService and connected
it to ConnectivityManager.

Bug: 176495254
Bug: 176494815
Test: atest FrameworksNetTests
atest FrameworksNetIntegrationTests
atest CtsNetTestCasesLatestSdk

Change-Id: Iabad7300a8b058e1edcb0defab8a031d21e6433c

James Mattis   commited 2021-02-04 20:12:40 -08:00
47db058602
Update OemNetworkPreferences to use 1:1 Map
Updated OemNetworkPreferences to use a Map instead of an Array of Arrays
(SparseArray<List<String>>). This is for two reasons: to make the API
simpler and also prevent issues with duplicate entries for packages
mapped to more than one preference which is not supported.

Bug: 176597181
Bug: 176494815
Test: atest FrameworksNetTests
Change-Id: I85363e28b46b89ae60a85219313c2a45bd5e7dd5

James Mattis   commited 2021-02-04 20:12:40 -08:00
e74935d4e6
Create new system API in UserHandle to get uid
For the incoming connectivity mainline, it need to compute the
intersection of a set of uids and appIds for the permission
control. As @UserIdInt values are internal implementation details
of the OS, any mainline modules should use strongly-typed
UserHandle arguments. Thus, create a new API that accepts
UserHandle and appId to get the computed uid.

Bug: 170598012
Test: atest FrameworksNetTests
Change-Id: I046546d2c5c76eac7a251e63e4234776975bf2bc

Chiachang Wang   commited 2021-02-05 02:26:23 +00:00
21fbe81e4c
Updating Existing CS APIs for multiple defaults
Updating existing ConnectivityService APIs to support multiple default
network functionality.

Bug: 178729499
Bug: 172347841
Test: atest FrameworksNetTests
atest NetworkStackTests
atest FrameworksNetIntegrationTests
atest NetworkStackIntegrationTests
atest CtsNetTestCasesLatestSdk

Change-Id: Ic41fdc402a26809efda71f484c259ffd7a52e63b

James Mattis   commited 2021-02-04 15:54:18 -08:00
2516da35fc
Transmitting multiple default networks to netd
Updating ConnectivityService to transmit network information to netd as
part of supporting multiple default networks.

Bug: 176191930
Bug: 172347841
Test: atest FrameworksNetTests
atest NetworkStackTests
atest FrameworksNetIntegrationTests
atest NetworkStackIntegrationTests
atest CtsNetTestCasesLatestSdk

Change-Id: I5851a36e3c3ccb45f4cb3ff85e0fc1352f64dc70

James Mattis   commited 2021-02-04 15:41:25 -08:00
d31bdfaa0c
[Mainline] Core Platform APIs migration
* java/net/InetAddress;->parseNumericAddress(Ljava/lang/String;)Ljava/net/InetAddress;
* libcore/io/IoUtils;->closeQuietly(Ljava/io/FileDescriptor;)V
* libcore/io/IoUtils;->closeQuietly(Ljava/lang/AutoCloseable;)V
* libcore/io/IoUtils;->setBlocking(Ljava/io/FileDescriptor;Z)V
* java/net/Inet4Address;->ANY:Ljava/net/InetAddress;
* java/net/Inet6Address;->ANY:Ljava/net/InetAddress;

Bug: 177260833
Test: mma
Change-Id: Iaddf1e9d912208b3982faea90aaa0fda80d9420a

Serik Beketayev   commited 2021-02-04 15:38:24 -08:00
0f518938b8
Merge changes from topic "nullablecollection"
* changes:
  API: Suppress existing NullableCollections lints (TaskOrganizer)
  API: Suppress existing NullableCollections lints

Adrian Roos   authored and   Gerrit Code Review   commited 2021-02-04 15:53:34 +00:00
318b03e4b0
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

paulhu   commited 2021-02-04 19:28:57 +08:00
f1530731c2
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

Aaron Huang   commited 2021-02-04 19:14:57 +08:00
54426716d2
Remove legacy network factories
Nothing on the system is using registerNetworkFactory,
unregisterNetworkFactory at the moment.

registerNetworkFactory, unregisterNetworkFactory are protected by
signature permissions, so could not be used by anything outside of the
system.

Remove the two methods and the underlying support for this legacy,
deprecated mechanism.

Bug: 179229316
Test: atest FrameworksNetTests
Change-Id: I7cdc9eed67f846c8774474af038133040aeccab3

Remi NGUYEN VAN   commited 2021-02-04 18:04:43 +09:00
2f7ba519fd
Merge "Revert the fallback naming into default network"
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-02-04 08:48:21 +00:00
ed69493b73
Merge "Improve getConnectionOwnerUid tests."
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2021-02-04 08:22:03 +00:00
69526b5212
Merge "Reimplement [read|write]ArraySet of Parcel inside NetworkCapabilities"
Lucas Lin   authored and   Gerrit Code Review   commited 2021-02-04 06:12:14 +00:00
cffb8610ab
[Mainline] Migrate android.utils package items
Bug: 177696419
Test: mma
Change-Id: Iaf99140d6153c1fe6674f6bf6077d54f1c8a20e9

Serik Beketayev   commited 2021-02-03 20:55:11 -08:00
5ff47a69e6
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

Lorenzo Colitti   commited 2021-02-04 04:19:28 +00:00
3be9df1ff7
Revert the fallback naming into default network
There is strong opposition in the team to this rename.
Reverting to the old language.

Test: FrameworksNetTests
Change-Id: Icefa3090966c07fd66692ddd5b44dfc94485a914

Chalard Jean   commited 2021-02-04 13:14:05 +09:00
5b409c7c9c
Merge changes Ifa2aa335,I09366a7f
* changes:
  Allow setting underlying networks when legacy lockdown enabled.
  Allow passing the underlying network to startLegacyVpn.

Lorenzo Colitti   authored and   Gerrit Code Review   commited 2021-02-03 14:07:44 +00:00
1b2443d1c5
Merge "Revert "Refactor setCurrentProxyScriptUrl to a void method""
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2021-02-03 13:05:35 +00:00
c4d0a33309
Allow setting underlying networks when legacy lockdown enabled.
Currently, if a legacy lockdown VPN is up, no VPN can set
underlying networks. This does not make much sense.

When legacy lockdown VPN is enabled, no other VPN is allowed to
call prepare() or establish(), so no other VPN can connect, and
if no VPN can connect, then no VPN can set underlying networks.
Therefore, disabling the ability to set underlying networks only
affects the legacy lockdown VPN itself.

This change is necessary because in a future CL, the legacy
lockdown VPN will start to inform ConnectivityService of its
underlying network.

Bug: 173331190
Test: tests in subsequent CLs in stack
Change-Id: Ifa2aa3351c2c8324571f96fda151864ed987ed5a

Lorenzo Colitti   commited 2021-02-03 19:04:17 +09:00
611cb26835
Allow passing the underlying network to startLegacyVpn.
This will be used by a future change that makes the legacy
lockdown VPN pass the underlying network.

Bug: 173331190
Test: tests in subsequent CLs in stack
Change-Id: I09366a7f872ef3d4538962a75b0114a2ecb536e6

Lorenzo Colitti   commited 2021-02-03 19:03:53 +09:00
c5383dcb45
Merge "[NS] Tests : don't expect a score in NF#acceptRequest"
Chalard Jean   authored and   Gerrit Code Review   commited 2021-02-03 08:10:19 +00:00
ab4b0cdccc
Revert "Refactor setCurrentProxyScriptUrl to a void method"
This reverts commit a42805cd7e.

Reason for revert: Broke HostsideVpnTests

Fix: 177943140
Change-Id: I23924181e46fd1f16a60ec420426d1ed39705050

Lorenzo Colitti   commited 2021-02-03 07:25:29 +00:00
bb4c3ac73f
Merge "Adding support for multiple "default" networks"
James Mattis   authored and   Gerrit Code Review   commited 2021-02-03 04:17:47 +00:00
e004fd3a44