Commit Graph

7967 Commits

Author SHA1 Message Date
Chiachang Wang
aa88bca82b Update state in NetworkInfo when network resumes
State override is only handled when state is changed from
CONNECTED to SUSPENDED but not reverse path. Handle both ways
for SUSPENDED state.

Bug: 148678431
Test: FrameworkNetTests
Change-Id: I9333f865d61bbf008fdb8ca162ad17dfdffd1d67
2020-02-14 16:41:33 +08:00
Benedict Wong
0bd4bba07a Enforce restricted user, getConnectionOwnerUid checks
This CL adds checks to ensure restricted users cannot change or
start/stop platform VPNs. In addition, this also adds checks to the
ConnectivityManager#getConnectionOwnerUid() to ensure that only
VpnService based VPNs can identify connections

Bug: 148040659
Test: FrameworksNetTests run
Change-Id: Id47ada5766036bfc84f3ba47f66f2d2683af916d
2020-02-14 00:09:47 -08:00
Roshan Pius
3d517a35aa [automerger skipped] Merge "RELAND: NetworkRequest: Embed requestor uid & packageName" am: 02d8578fc3 -s ours
am skip reason: Change-Id I207c446108afdac7ee2c25e6bbcbc37c4e3f6529 with SHA-1 d499517306 is in history

Change-Id: Ib90134e63ac00f6b377d27d1d8f2a125a247d724
2020-02-14 02:09:17 +00:00
Roshan Pius
02d8578fc3 Merge "RELAND: NetworkRequest: Embed requestor uid & packageName" 2020-02-14 01:57:49 +00:00
Benedict Wong
2af84b64bb Merge "Implement Ikev2VpnRunner" am: 02e9b56db8
Change-Id: I9b966b52f78fa54dca9d8c3032ec26ed853ad572
2020-02-13 21:31:28 +00:00
Benedict Wong
02e9b56db8 Merge "Implement Ikev2VpnRunner" 2020-02-13 21:15:24 +00:00
Benedict Wong
969d188edb Implement Ikev2VpnRunner
This change adds the implementation for IKEv2/IPsec VPNs.

Bug: 144246767
Test: Manually tested
Change-Id: I5ccec756cec49ccf57ccc4d5ad800eeb5d595a76
Merged-In: I5ccec756cec49ccf57ccc4d5ad800eeb5d595a76
2020-02-13 18:37:06 +00:00
Automerger Merge Worker
ef5b92c7d2 Merge "Add Intdef annotation for eventId in logEvent" am: 2ed536a7b6
Change-Id: Ic9b5ea605164340d5c2461eb7a1a752bb5b36bad
2020-02-13 10:56:35 +00:00
Chiachang Wang
2ed536a7b6 Merge "Add Intdef annotation for eventId in logEvent" 2020-02-13 10:44:57 +00:00
Automerger Merge Worker
9dd19a4b83 Merge "Add permission check for CaptivePortal#reevaluateNetwork" am: d0f3cb625e
Change-Id: I2f9de2582025c8fc3782870b8c561ce2002abaf8
2020-02-13 06:54:50 +00:00
Chiachang Wang
d0f3cb625e Merge "Add permission check for CaptivePortal#reevaluateNetwork" 2020-02-13 06:41:53 +00:00
Chiachang Wang
2520c650cd Add Intdef annotation for eventId in logEvent
Follow API guide.

Bug: 148379628
Test: make test-api-stubs-docs-update-current-api \
      system-api-stubs-docs-update-current-api

Change-Id: I410ef06b2fa82d8ef35513086733b0fc2cf0fe06
2020-02-13 06:26:35 +00:00
Roshan Pius
08c94fb8a9 RELAND: NetworkRequest: Embed requestor uid & packageName
Add the requestorUid & requestorPackageName fields to
NetworkCapabilities. This is populated by CS when
a new network request is received.
These 2 requestor fields are also optionally used for network
matching. All of the regular app initiated requests will have the
requestor uid and package name set by connectivity service. Network
agents can optionally set the requestorUid and requestorPackageName
to restrict the network created only to the app that requested the network.

This will help removing the necessity for the various specifiers to embed
the uid & package name info in the specifier for network matching.

Note: NetworkSpecifier.assertValidFromUid() is deprecated & removed in
favor of setting the uid/package name on the agent to restrict the
network to a certain app (useful for wifi peer to peer API & wifi aware).

Bug: 144102365
Test: Verified that wifi network request related CTS verifier tests
pass.
Test: Device boots up and connects to wifi networks
Merged-In: I207c446108afdac7ee2c25e6bbcbc37c4e3f6529

Change-Id: I58775e82aa7725aac5aa27ca9d2b5ee8f0be4242
2020-02-12 16:58:36 -08:00
Automerger Merge Worker
9e1c910fff Merge "Revert "NetworkRequest: Embed requestor uid & packageName"" am: 948f0f9878
Change-Id: I00dd341f699d2a22cc3d190b43314a49bee9062a
2020-02-12 23:55:00 +00:00
Roshan Pius
948f0f9878 Merge "Revert "NetworkRequest: Embed requestor uid & packageName"" 2020-02-12 23:36:13 +00:00
Roshan Pius
d85de75bfa Revert "NetworkRequest: Embed requestor uid & packageName"
This reverts commit d499517306.

Reason for revert: b/149425896
Bug: b/149425896

Change-Id: I9fe31509c040cc421ccb00ea60f15e6f199e8bc6
2020-02-12 23:33:43 +00:00
Automerger Merge Worker
e6f588ab90 Merge "NetworkRequest: Embed requestor uid & packageName" am: 7b59ec507c
Change-Id: Ic4f9247e18a9d1cc22b26500b47da1af2d9b011d
2020-02-12 18:51:59 +00:00
Qingxi Li
7b59ec507c Merge "NetworkRequest: Embed requestor uid & packageName" 2020-02-12 18:43:32 +00:00
Cody Kesting
d876b4ef76 Merge "Include NetworkCapabilities and LinkProperties in DataStallReport."
am: 287c4adbc9

Change-Id: If2157b0dd7d62560c77318b76e0d7d2a66c09644
2020-02-12 09:16:41 -08:00
Cody Kesting
287c4adbc9 Merge "Include NetworkCapabilities and LinkProperties in DataStallReport." 2020-02-12 16:38:38 +00:00
Automerger Merge Worker
518e36415a Merge changes from topic "NS-A44_lingerstate" am: 34587c19ce
Change-Id: Ibec8f280ad0b256d3d9b065a541063fc63d5a356
2020-02-12 15:29:30 +00:00
Chalard Jean
34587c19ce Merge changes from topic "NS-A44_lingerstate"
* changes:
  [NS B10] Cleanup : remove mRematchedNetworks
  [NS B09] Create NetworkRanker
  [NS B08] More simplification
  [NS B07] More simplification
  [NS B06] Simplification
  [NS B05] Remove old dead code
  [NS B04] Make the network selection request-major.
  [NS B03] Add debug log showing the reassignment
  [NS B02] Split out a function to apply a NetworkReassignment
  [NS B01] Move the computation loop to a separate function
  [NS A44 2/2] Apply requests after all networks rematching is computed
  [NS A44 1/2] Update linger state before processing listens
2020-02-12 15:13:10 +00:00
Chalard Jean
b10ab41350 [NS B10] Cleanup : remove mRematchedNetworks
This is better computed by the code that applies the change
than by the code that computes the reassignment

Test: FrameworksNetTests
Change-Id: I13e2764fd9b29145499085c3bb56de88a97d6c3c
2020-02-12 21:23:45 +09:00
Chalard Jean
96a4f4b8de [NS B09] Create NetworkRanker
Bug: 113554781
Test: FrameworksNetTests
Change-Id: Ia534247144f479fe896e1a6e05b906103cd10005
2020-02-12 20:57:45 +09:00
Chalard Jean
f955f8eb6c [NS B08] More simplification
Only computing the reassignment does not actually change the
default network.

Test: FrameworksNetTests
Change-Id: I21ddf5cc1e3d3817055dbda4246e38ceb0732407
2020-02-12 20:57:44 +09:00
Chalard Jean
a6014db965 [NS B07] More simplification
The new reassignment does not contain these useless lines
any more.

Test: FrameworksNetTests
Change-Id: I1583aebe94e529ce2b36e191a6e1f49c976bf29a
2020-02-12 20:57:44 +09:00
Chalard Jean
46a62378ec [NS B06] Simplification
This check is now unnecessary, seeing how the code adding these
changes is now guaranteed to only add at most one change for
each request.

Test: FrameworksNetTests
Change-Id: Ia0443602d9c89ee413e956df9c7b79f8f74813f7
2020-02-12 20:57:43 +09:00
Chalard Jean
7feb6ed384 [NS B05] Remove old dead code
Test: FrameworksNetTests
Change-Id: I553721b327b76ede0e76b9fb7a0130fcae012175
2020-02-12 20:52:17 +09:00
Chalard Jean
857a1719a1 [NS B04] Make the network selection request-major.
This patch marks the most important turning point of this
refactoring. Cleanups removing unused code will follow.

Replace the old network-major reassignment computation with a
much simpler and faster loop that takes each request and assigns
it the highest-scoring network.

All tests pass, of course.

Bug: 113554781
Test: FrameworksNetTests
Change-Id: Ie143802995155151a38a4eb1d2f26c3f29e556bd
2020-02-12 20:52:17 +09:00
Chalard Jean
4970757c26 [NS B03] Add debug log showing the reassignment
dumpString for a reassignment looks like :

NetworkReassignment :
  Rematched networks : [100 CELLULAR], [101 WIFI]
  6 : 100 → 101
  8 : null → 101

toString looks like :

NetReassign [4 : 100 → 101, 5 : null → 101]

If no changes, then it looks like
NetworkReassignment : no changes

Bug: 113554781
Test: Manual
Change-Id: If9eeadb7ee317dee2d91ca1feca3091ae39e9bae
2020-02-12 20:52:17 +09:00
Chalard Jean
d7f762d7be [NS B02] Split out a function to apply a NetworkReassignment
This makes the rematchAllNetworksAndRequests function, which
is the nexus of the rematching code, very straightforward and
easy to read.

Bug: 113554781
Test: FrameworksNetTests
Change-Id: I5cea4ed7e06439494700d88ab202b696402fa360
2020-02-12 20:52:17 +09:00
Chalard Jean
57cc7cb461 [NS B01] Move the computation loop to a separate function
Bug: 113554781
Test: FrameworksNetTests
Change-Id: I6c28c7af5c600d35aa1e9328b6c988dadb921f51
2020-02-12 20:52:17 +09:00
Chalard Jean
64520dc488 [NS A44 2/2] Apply requests after all networks rematching is computed
This patch finally separates completely computing the rematch
from all the side effects. A collateral effect of this is to
compute correctly the background network state in
rematchNetworkAndRequests, which compensates the breakage
from the previous patch.

Bug: 113554781
Test: ConnectivityServiceTest
Change-Id: I998c729c385940168fcd6ba3f2e01911f1844ce1
2020-02-12 20:52:17 +09:00
Chalard Jean
6a4dfac6b8 [NS A44 1/2] Update linger state before processing listens
To compute accurately whether a network is in the background, the
linger state needs to be updated. Do that before computing whether
a network is in the background and possibly calling
applyBackgroundChangeForRematch.

However ! As of this patch, rematchNetworksAndRequests computes
a wrong value when adding to the list of affected networks, because
it is looking at intermediate global state. Somehow this used to
compensate exactly for the way reading back the state was wrong.
There might have been a few undetected bugs there, but none is
known.

As such, as of this patch, rematchNetworksAndRequests still
computes a wrong value while the computation when applying that
state now computes the right one, so the tests do not pass.
This patch must be checked in together with A44 2/2 which will
fix the computation in rematchNetworksAndRequests, but is kept
separate for ease of review.

Bug: 113554781
Test: ConnectivityServiceTest
Change-Id: Iaeed0d11bfa09f292f232ae020e944e430bc0184
2020-02-12 20:52:17 +09:00
Chiachang Wang
f7a0f125db Add permission check for CaptivePortal#reevaluateNetwork
CaptivePortal#reevaluateNetwork is added as a system API which
requires a proper permission check.

Bug: 148379628
Test: Manually check with captive portal
Test: atest FrameworksNetTests
Test: make test-api-stubs-docs-update-current-api \
      system-api-stubs-docs-update-current-api

Change-Id: I3f974339d5bd53a6f6ecb0842c02a8264dc3a5f9
Merged-In: I559d42089aeb09801d14c251c5165fca793c3cb3
2020-02-12 11:29:24 +00:00
Automerger Merge Worker
54a520d22f Merge changes Ibc9b1965,I288ea32f am: 7fa63afe6d
Change-Id: I6eb675ddfa609dcc3031e916ce49959e42cf53f6
2020-02-12 06:25:49 +00:00
Automerger Merge Worker
1021194560 Add a systemapi constructor for NetworkAgent am: 0900154ef5
Change-Id: I3fa3ec32d3c580ba0b7f2d515e08d27dd6af5bcd
2020-02-12 06:25:42 +00:00
Aaron Huang
c2b200e46b Fix invalid usage of javadoc
CP from ag/10125651

Test: this change removes invalid usage
Change-Id: Ibc9b1965ec7aa545c0dae71d741c3802d3a9fa12
Merged-In: I35fc4a814238635fa95981649c27230dda319afa
2020-02-12 06:10:10 +00:00
Roshan Pius
d499517306 NetworkRequest: Embed requestor uid & packageName
Add the requestorUid & requestorPackageName fields to
NetworkCapabilities. This is populated by CS when
a new network request is received.
These 2 requestor fields are also optionally used for network
matching. All of the regular app initiated requests will have the
requestor uid and package name set by connectivity service. Network
agents can optionally set the requestorUid and requestorPackageName
to restrict the network created only to the app that requested the network.

This will help removing the necessity for the various specifiers to embed
the uid & package name info in the specifier for network matching.

Note: NetworkSpecifier.assertValidFromUid() is deprecated & removed in
favor of setting the uid/package name on the agent to restrict the
network to a certain app (useful for wifi peer to peer API & wifi aware).

Bug: 144102365
Test: Verified that wifi network request related CTS verifier tests
pass.
Test: Device boots up and connects to wifi networks
Change-Id: I207c446108afdac7ee2c25e6bbcbc37c4e3f6529
Merged-In: I207c446108afdac7ee2c25e6bbcbc37c4e3f6529
2020-02-12 04:42:58 +00:00
Cody Kesting
f2852480a0 Include NetworkCapabilities and LinkProperties in DataStallReport.
DataStallReport is updated to include the NetworkCapabilities and Link
Properties for the Network being reported on. This provides a more
complete picture of the Network conditions when the suspected data stall
was detected.

Bug: 148966398
Test: atest FrameworksNetTests
Change-Id: I913cf18c348b9f688f9d2a3d25a71bc94eb8f000
2020-02-11 08:50:59 -08:00
Chalard Jean
0900154ef5 Add a systemapi constructor for NetworkAgent
Bug: 138306002
Bug: 139268426
Test: atest FrameworksNetTests FrameworksWifiTests FrameworksTelephonyTests
      make doc-comment-check-docs
Change-Id: I288ea32fac07a9a486e2ea451a2c9b098446a74c
Merged-In: I288ea32fac07a9a486e2ea451a2c9b098446a74c
2020-02-11 16:26:10 +08:00
Automerger Merge Worker
79a71ed587 [automerger skipped] Merge "Fix review comments on aosp/1213524" am: 100e0b9a51 -s ours
am skip reason: Change-Id I621cfbe165996c67b201ca2dd2f95a5ab9af10ee with SHA-1 ab2fed7241 is in history

Change-Id: I1016fc76028aeafa9f15841b4e2951957aa11578
2020-02-11 03:43:38 +00:00
Aaron Huang
100e0b9a51 Merge "Fix review comments on aosp/1213524" 2020-02-11 03:33:08 +00:00
Chalard Jean
75a6104e2a Fix review comments on aosp/1213524
This is necessary to avoid subsequent conflicts.

Test: none needed
Change-Id: I6e2cd9188e0e4bd7c71c6c56635f192dce73f325
Merged-In: I621cfbe165996c67b201ca2dd2f95a5ab9af10ee
2020-02-10 08:28:04 +00:00
Automerger Merge Worker
40c31cb9ee Merge "rm libbinderthreadstate" am: fc72c2ee39
Change-Id: Ib7de947aa4ee5b349c9576355869702ac94d8624
2020-02-09 23:27:45 +00:00
Treehugger Robot
fc72c2ee39 Merge "rm libbinderthreadstate" 2020-02-09 23:06:21 +00:00
Automerger Merge Worker
ad0dc3c5b3 Merge "[NS A43] Separate updating the linger timer and sending LOSING" am: 30394e2a2b
Change-Id: I4b8e7eec2df77d04700582542d6f3f2fb455c2af
2020-02-09 07:06:13 +00:00
Automerger Merge Worker
52aa90906f Merge "[NS A42] Move writing to the reassignment to the computation" am: 358eb47a06
Change-Id: Ic04c72d0720bb53a38329dbcbc75cd914e1296c0
2020-02-09 07:05:54 +00:00
Chalard Jean
30394e2a2b Merge "[NS A43] Separate updating the linger timer and sending LOSING" 2020-02-09 06:51:06 +00:00
Chalard Jean
358eb47a06 Merge "[NS A42] Move writing to the reassignment to the computation" 2020-02-09 06:50:48 +00:00