Commit Graph

152 Commits

Author SHA1 Message Date
Lorenzo Colitti
7d9f43c6f3 Merge "Don't send onLinkPropertiesChanged after onLost for 464xlat." am: a3f12dd52c am: b4e1b65298
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1727829

Change-Id: Iad96cfcdd5f385c084be76b3b25ffd10b080df7f
2021-06-09 08:33:36 +00:00
Lorenzo Colitti
a3f12dd52c Merge "Don't send onLinkPropertiesChanged after onLost for 464xlat." 2021-06-09 07:59:25 +00:00
Junyu Lai
5b15e700bb Merge changes from topics "enable-policy-ranking", "sendNetworkScore"
* changes:
  Adjust a test for policy scoring
  Enable policy ranking
  Add CTS to verify NetworkAgent#setLingerDuration
  Allow network providers to set the linger duration.
  Fix nascent timer never get removed
  [NS13] Remove the last usage of the legacy int
  Add documentation
  Use filter from CollectionUtils.
  Fix a bug where updates of offers won't find existing offers
  [NS12] Address comments on NS09
  [NS11] Fix yieldToBadWifi over the policy scoring
  Add doc for NetworkScore#getLegacyInt
  Expose sendNetworkScore that takes a NetworkScore
2021-06-08 22:34:44 +00:00
Remi NGUYEN VAN
674ce27fee Merge changes from topic "framework-conn-stub-cp"
* changes:
  Reference framework-connectivity stubs explicitly
  Merge framework-connectivity impl and stub targets
2021-06-08 09:15:15 +00:00
Remi NGUYEN VAN
12474fdab5 Merge "Add min_sdk_version to connectivity targets" 2021-06-08 08:44:21 +00:00
Paul Hu
7cba5f4163 Merge "Move UIDS_ALLOWED_ON_RESTRICTED_NETWORKS setting" 2021-06-08 07:23:39 +00:00
Lorenzo Colitti
b4bf015b57 Don't send onLinkPropertiesChanged after onLost for 464xlat.
Currently, when a network that uses 464xlat is torn down,
NetworkCallbacks will receive onLinkPropertiesChanged after
onLost. This is confusing and incorrect.

The incorrect callback is sent because handleLinkProperties
checks that the netId of the agent still exists, not that the
NetworkAgent is still registered. This is normally correct,
because the NetworkAgent is removed from mNetworkAgentInfos and
the netId are removed from mNetworkForNetId by the same method,
disconnectAndDestroyNetwork.

In this specific case it's not correct, because the call to
handleUpdateLinkProperties is from disconnectAndDestroyNetwork
itself via nai.clatd.update and calls Nat464Xlat#stop.

No other callers of handleUpdateLinkProperties are affected
because:

- EVENT_NETWORK_PROPERTIES_CHANGED is called only by
  maybeHandleNetworkAgentMessage, which first checks that the
  NetworkAgent is registered.
- handlePrivateDnsSettingsChanged only looks at registered
  NetworkAgents (it loops over mNetworkAgentInfos).
- handlePrivateDnsValidationUpdate, handleNat64PrefixEvent and
  handleCapportApiDataUpdate call getNetworkAgentInfoForNetId,
  which will correctly determine that the agent is no longer
  registered, since they run on the handler thread and thus
  cannot run at the same time as disconnectAndDestroyNetwork.

The existing code contains a check for the netId being current.
This is intended to ensure that an update from a NetworkAgent
cannot affect another agent with the same Network. This extra
check is not necessary, because code running on the handler
thread can never observe a NetworkAgent in mNetworkAgentInfos
unless mNetworkForNetId maps that NetworkAgent's Network to that
NetworkAgent. This is because mNetworkForNetId is updated by the
same methods as mNetworkAgentInfos, and those updates occur on
the handler thread. So all code on the handler thread will see
those two as consistent.

Bug: 176496580
Test: atest FrameworksNetTests CtsNetTestCases HostsideVpnTests
Change-Id: I944f4c6ad36206bdccd85a6ea7ef71324a29c685
2021-06-08 15:48:57 +09:00
Remi NGUYEN VAN
e70cd84601 Merge framework-connectivity impl and stub targets
Instead of using api_only: true, use a single java_sdk_library to
generate both framework-connectivity stubs and
framework-connectivity.impl.

Original change (project moved):
I76d7cf1ba31a3f38ae6b9facbf1b668860c8c165

Bug: 183600168
Test: m
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Change-Id: I07d8c4c92c91939b8e8890fdb5db517b75faee2c
2021-06-08 15:24:05 +09:00
Remi NGUYEN VAN
da43ef0b68 Add min_sdk_version to connectivity targets
All targets need min_sdk_version 30 to be included in the tethering
APEX. They will actually never be used on SDK 30 and are only loaded on
31, but this is necessary to be included in com.android.tethering.

Original change (project moved):
I190fd1f3c9fabff057d0a2bd7f45b63a4fe447b3

This also includes changes to the lint baseline to make it match actual
filenames.

Bug: 171540887
Test: m
Test: m lint-check
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Change-Id: I24198565bc98d85d0c036be02e3a6c311b5bb2a3
2021-06-08 15:23:40 +09:00
Paul Hu
e2791b00d3 Merge "Address leftover comments" 2021-06-08 06:18:19 +00:00
Remi NGUYEN VAN
8665528151 Merge "Revert "Add min_sdk_version to connectivity targets"" 2021-06-08 04:52:03 +00:00
Remi NGUYEN VAN
ccd2a6aeb4 Revert "Add min_sdk_version to connectivity targets"
This reverts commit 0b900c91f6.

Reason for revert: Broke errorprone: b/190454846

Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Change-Id: I21de7e7e06daa5f4a688b4246986f8d44da97c91
Fixes: 190454846
2021-06-08 04:50:01 +00:00
Remi NGUYEN VAN
bf7cffa7a0 Merge "Add min_sdk_version to connectivity targets" 2021-06-08 04:38:30 +00:00
Remi NGUYEN VAN
8bf9411324 Merge "Add lint baseline to address NewApi errors" 2021-06-08 03:28:26 +00:00
Remi NGUYEN VAN
0b900c91f6 Add min_sdk_version to connectivity targets
All targets need min_sdk_version 30 to be included in the tethering
APEX. They will actually never be used on SDK 30 and are only loaded on
31, but this is necessary to be included in com.android.tethering.

Original change (project moved):
I190fd1f3c9fabff057d0a2bd7f45b63a4fe447b3

Bug: 171540887
Test: m
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Change-Id: I3db00acc79b11058a1c235916b9bfe6c759afda5
2021-06-08 09:28:26 +09:00
Pedro Loureiro
8f16b39776 Add lint baseline to address NewApi errors
We are enabling a new lint check where the min sdk != compile sdk.
It has produced a lot of errors and adding the baseline file(s)
allows us to continue work without introducing more problems.

This is a partial cherry-pick of change merged downstream.

Bug: 150847901

Test: m lint-check
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Change-Id: I214d60e858b7c03885d4d1c9a083e67a9340b4fe
2021-06-08 09:28:12 +09:00
Chalard Jean
f4c48a4d5f Enable policy ranking
Test: Passes all presubmits, been tested in labs
Bug: 184834350
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: If33884aa245bcc8817bbc9c2fdfab035249e7301
Change-Id: If33884aa245bcc8817bbc9c2fdfab035249e7301
  (cherry-picked from ag/14150470)
2021-06-08 00:17:38 +00:00
Chalard Jean
550b5214d3 Allow network providers to set the linger duration.
Test: atest CtsNetTestCases:NetworkAgentTest#testSetLingerDuration
CTS-Coverage-Bug: 184796264
Bug: 184227264
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: I7f420faa40863385114705d6971cf00887d03318
Change-Id: I7f420faa40863385114705d6971cf00887d03318
  (cherry-picked from ag/14100410)
2021-06-08 00:17:37 +00:00
junyulai
36c02987c6 Fix nascent timer never get removed
By design, the nascent timer will be removed after a network
satisfied first request. However, this never happens.
Because the mInactive is false when that happens, so isNascent
is never true.

Furthermore, when removing a nascent timer, the inactivity
state can never be updated since no condition in the
updateInactivityState will be met to update the state correctly.

Thus, update inactive state accordingly when adding/removing the
nascent timer.

Test: TH
Bug: 184227264
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: I4c1521b6e0ef68ac489771a2ab6b09ef3e381577
Change-Id: I4c1521b6e0ef68ac489771a2ab6b09ef3e381577
  (cherry-picked from ag/14060609)
2021-06-08 00:17:37 +00:00
Chalard Jean
c81d4c3c7e [NS13] Remove the last usage of the legacy int
Note that this requires removing part of a test, because
that part is testing that the a 50 bonus of the legacy
int is stronger than the validation penalty, which is
not a mechanic we want to have. When WiFi is unvalidated
and cell is unvalidated, cell should be kept in case it
validates, like is described in comments in
isNetworkPotentialSatisfier ; however this test is
checking that it *IS* reaped off if the wifi score is
strong enough. This should be incorrect, and should not
be tested, so this patch removes the check.

Test: ConnectivityServiceTest
Bug: 184834350
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: I8966abee59fea2d9f10f082aba87df6588b72762
Change-Id: I8966abee59fea2d9f10f082aba87df6588b72762
  (cherry-picked from ag/14127306)
2021-06-08 00:17:37 +00:00
Chalard Jean
5e8f8431d8 Use filter from CollectionUtils.
Test: ConnectivityServiceTest
Fixes: 184826320
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: Iae8df6058c0a43fba1e6ebcd6003df54751f9646
Change-Id: Iae8df6058c0a43fba1e6ebcd6003df54751f9646
  (cherry-picked from ag/14125157)
2021-06-08 00:17:36 +00:00
Chalard Jean
9f6d447a42 Fix a bug where updates of offers won't find existing offers
.equals() only work on cross-process Binder instances if casted to
a Binder instance first.

Bug: 184281544
Test: ConnectivityServiceTest. CTS test for this specific issue to come
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: I7b9e0df21a3cca59659867a75792289ddee2f1d7
Change-Id: I7b9e0df21a3cca59659867a75792289ddee2f1d7
  (cherry-picked from ag/14125149)
2021-06-08 00:17:36 +00:00
Chalard Jean
29cb06a3e0 [NS12] Address comments on NS09
Test: ConnectivityServiceTest
Fixes: 184507247
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: Ic4500dc85507fa68538c9ec179ec6eb4f44c5022
Change-Id: Ic4500dc85507fa68538c9ec179ec6eb4f44c5022
  (cherry-picked from ag/14091168)
2021-06-08 00:17:36 +00:00
Chalard Jean
142f0fe4d4 [NS11] Fix yieldToBadWifi over the policy scoring
This doesn't reactivate the test because it's not yet fixed over int
scoring.

Bug: 184834350
Test: Remove @Ignore and run testAvoidBadWifi
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: I32477db52eb50faabc499fa68e24ba07577782aa
Change-Id: I32477db52eb50faabc499fa68e24ba07577782aa
  (cherry-picked from ag/14064906)
2021-06-08 00:17:36 +00:00
Treehugger Robot
0deed353b7 Merge "Require location permission for ConnDiags WiFi only." am: 5cfbc2e4cc am: 058e8f9f28
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1718590

Change-Id: I10a6a9c97cf7bfdde877a9d061b03990a830833c
2021-06-07 19:22:18 +00:00
Junyu Lai
217f4ad9b1 Merge "[NS10] Fix a bug where registerIgnoringScore is broken" 2021-06-07 18:53:37 +00:00
Treehugger Robot
5cfbc2e4cc Merge "Require location permission for ConnDiags WiFi only." 2021-06-07 18:44:48 +00:00
Chalard Jean
94ca04b255 [NS10] Fix a bug where registerIgnoringScore is broken
Fixes: 184028345
Test: ConnectivityServiceTest
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: Ib5cd2c27a2bd0f53b500e8edbe48126fbf58f34d
Change-Id: Ib5cd2c27a2bd0f53b500e8edbe48126fbf58f34d
  (cherry-picked from ag/14034625)
2021-06-07 11:00:49 +00:00
Chalard Jean
e4aeac6d75 [NS09] Implement the new ranking code
At this stage, this is turned off. Unit tests will be
in a followup change.

Test: In a followup
Bug: 167544279
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: I4448a3546fbc1a3dddf757982c031c5f39ba2889
Change-Id: I4448a3546fbc1a3dddf757982c031c5f39ba2889
  (cherry-picked from ag/14010222 with fixes)
2021-06-07 11:00:46 +00:00
Chalard Jean
f3ff362210 [NS07] Add the rest of the scoring policy
Bug: 167544279
Test: FrameworksNetTests
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: I5ea44a94ac6f16486274e9091f15a84734db2341
Change-Id: I5ea44a94ac6f16486274e9091f15a84734db2341
  (cherry-picked from ag/13988828)
2021-06-07 10:57:49 +00:00
Chalard Jean
947acd4275 [NS06] Implement the don't-reap mechanism
This exposes a mechanism for network providers to tell
the network stack that a given network must be kept up
for some specific reason. This is meant to be easier
for them than to have to file a request, in particular
because there is no guaranteed way to make sure the
request will be best matched by any given network.

Test: new test for this
Bug: 167544279
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: I238a3ee5ee9262477a23b897e4141769dd1505d1
Change-Id: I238a3ee5ee9262477a23b897e4141769dd1505d1
  (cherry-picked from ag/13929760)
2021-06-07 10:57:49 +00:00
Chalard Jean
0354d8c7e0 [NS05] Feed network offer callbacks
The design is very simply expressed :
An offer is needed for a request if and only if that offer
might beat the satisfier for that request.

The implementation of "might beat" is NetworkRanker#mightBeat.

Test: FrameworksNetTests FrameworksWifiTests NetworkStackTests
Bug: 167544279
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: I0fe911eef2483ecbac48c733d56283b81538690a
Change-Id: I0fe911eef2483ecbac48c733d56283b81538690a
  (cherry-picked from 7b6a33bd50)
2021-06-07 10:57:48 +00:00
Paul Hu
9bd5882024 Merge "Move UIDS_ALLOWED_ON_RESTRICTED_NETWORKS setting" into sc-dev am: 48fc715694
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/14772857

Change-Id: I45b1bc2e2930454d8a7fb662153d46e762da62b4
2021-06-07 09:48:36 +00:00
Paul Hu
48fc715694 Merge "Move UIDS_ALLOWED_ON_RESTRICTED_NETWORKS setting" into sc-dev 2021-06-07 09:29:56 +00:00
Paul Hu
31218d45ae Merge "Address leftover comments" into sc-dev am: 9a8e4497a3
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/14772851

Change-Id: I6e3a372dd3593a295fbde5785b1bb7d9004a313c
2021-06-07 09:02:00 +00:00
Remi NGUYEN VAN
3c5921caea Merge "Revert "Add min_sdk_version to connectivity targets"" 2021-06-07 08:58:15 +00:00
Remi NGUYEN VAN
0ad52839e7 Revert "Add min_sdk_version to connectivity targets"
This reverts commit 326f7bb023.

Reason for revert: broke errorprone:
"Error: Call requires API level 31 (current min is 30)"

Bug: 190350403
Change-Id: Ib778ba7a882dabc4d42ab9689e1cc51d09d9be62
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
2021-06-07 08:56:05 +00:00
paulhu
4428044569 Move UIDS_ALLOWED_ON_RESTRICTED_NETWORKS setting
Now, PermissionMonitor reigster observer to listen the change
from all users, but "uids allowed on restricted networks" should
affect to all users instead of per each user. Thus, move the
setting from Settings.Secure to Settings.Global.

Bug: 189705071
Test: atest FrameworksNetTests
Merged-In: Ibea354d8dda1f02652a193820f3f9eb573b9a956

Change-Id: Ibea354d8dda1f02652a193820f3f9eb573b9a956
2021-06-07 08:55:16 +00:00
paulhu
eb43848207 Address leftover comments
- Add comment to highestPermissionForUid()
- Add testAppsAllowedOnRestrictedNetworksChangedMultipleUsers
- Add synchronized to guard mUidsAllowedOnRestrictedNetworks
  access.

Bug: 189705071
Test: atest FrameworksNetTests
Merged-In: I9056758db15e8a21b84ef244d4cacf24c3b79894

Change-Id: I9056758db15e8a21b84ef244d4cacf24c3b79894
2021-06-07 08:54:12 +00:00
Paul Hu
9a8e4497a3 Merge "Address leftover comments" into sc-dev 2021-06-07 08:50:21 +00:00
Paul Hu
0a0d7c99c9 Merge "Implement mobile data preferred uids feature" 2021-06-07 06:46:59 +00:00
Remi NGUYEN VAN
51c61941ea Merge "Add min_sdk_version to connectivity targets" 2021-06-07 05:18:01 +00:00
Remi NGUYEN VAN
c006592307 Merge "Build service-connectivity with system_server API" 2021-06-07 05:17:21 +00:00
paulhu
51f77dcc49 Implement mobile data preferred uids feature
- Read MOBILE_DATA_PREFERRED_UIDS setting when system ready
- Register MOBILE_DATA_PREFERRED_UIDS setting observer
- Send uid ranges to netd when update mobile data preferred uids

Bug: 171872461
Test: atest FrameworksNetTests
Merged-In: I5153c770650594e05dfa8cf230d7381d790f4a55
(cherry-pick with minor conflicts)

Change-Id: I5153c770650594e05dfa8cf230d7381d790f4a55
2021-06-07 02:55:25 +00:00
Junyu Lai
9756b5d4f9 Merge changes Ia930b3d3,If614da81,I975a9439
* changes:
  [NS04.8] Address comments from NS04 and NS04.5
  [NS04.7] Reinstate a necessary change
  [NS04.5] Have NetworkOffer embark a provider ID
2021-06-04 20:52:38 +00:00
Paul Hu
c30c57c210 Merge "Update allowed on restricted networks getter/setter" 2021-06-04 10:31:50 +00:00
Paul Hu
7a3102f0f5 Merge "Implement mobile data preferred uids feature" into sc-dev am: 87f2897f90
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/14732015

Change-Id: I2528dad0ebc73284cf544b1b2e2bd673e5fd69a2
2021-06-04 09:11:35 +00:00
Paul Hu
87f2897f90 Merge "Implement mobile data preferred uids feature" into sc-dev 2021-06-04 08:55:31 +00:00
Chalard Jean
dd35f2dab0 [NS04.7] Reinstate a necessary change
NS04.5 removed a security that it shouldn't have. Reinstate it.

Bug: 167544279
Test: ConnectivityServiceTest
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: If614da813a96d1b50a16fa4be5659e1647d9469d
Change-Id: If614da813a96d1b50a16fa4be5659e1647d9469d
  (cherry-picked from ag/13975118)
2021-06-04 02:37:40 +00:00
Chalard Jean
30689b8fd7 [NS04.5] Have NetworkOffer embark a provider ID
...instead of a Messenger.
This will be useful later to compare whether a given offer is
offered by the same provider satisfying a request.

Bug: 167544279
Test: ConnectivityServiceTest
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: I975a9439021c7fa511c50ac982819b6dd146291e
Change-Id: I975a9439021c7fa511c50ac982819b6dd146291e
  (cherry-picked from 148dcce559)
2021-06-04 02:36:58 +00:00