Commit Graph

216 Commits

Author SHA1 Message Date
Remi NGUYEN VAN
4ca7a11543 Merge "Remove ConnectivityServiceTest signature perms use" am: 54c7434f0d am: 96ad425c5e am: 595dda3604
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1736615

Change-Id: I7dd3c5e7da9097ebedd7f4a836d4e78ef9bf08e5
2021-06-16 11:49:54 +00:00
Remi NGUYEN VAN
595dda3604 Merge "Remove ConnectivityServiceTest signature perms use" am: 54c7434f0d am: 96ad425c5e
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1736615

Change-Id: Ifd8c397644f5fc680b34905882ec287bb43c1e1b
2021-06-16 11:37:53 +00:00
Remi NGUYEN VAN
54c7434f0d Merge "Remove ConnectivityServiceTest signature perms use" 2021-06-16 11:09:05 +00:00
Remi NGUYEN VAN
18a979fa41 Remove ConnectivityServiceTest signature perms use
To allow unit tests to run without platform certificates, remove
signature permission usage in ConnectivityServiceTest.

This mocks permission checks done in ConnectivityService for which the
test assumed that the permission was held, and mocks calls to
BatteryStatsManager. Calls to ActivityManagerService (through
PendingIntent) are done with shell permissions as the test uses real
PendingIntent mechanics.

Bug: 187935317
Test: atest FrameworksNetTests
Change-Id: If309d653ac2e9bbcf1b94bcee6336367289df359
2021-06-16 16:32:03 +09:00
James Mattis
c415441129 Update CS so that per-app OEM APIs can be tested am: fa270db5f7 am: 6c54d5e4c4 am: 39a42aefc6
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1723050

Change-Id: I6b8d4269db7592a2c9bafca480bac184e46736fa
2021-06-16 01:57:47 +00:00
James Mattis
39a42aefc6 Update CS so that per-app OEM APIs can be tested am: fa270db5f7 am: 6c54d5e4c4
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1723050

Change-Id: I5f8bc3a60d92e86047debd9363e5dddf06da6ee8
2021-06-16 01:30:05 +00:00
James Mattis
6c54d5e4c4 Update CS so that per-app OEM APIs can be tested am: fa270db5f7
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1723050

Change-Id: Ib5937d0fd732f915416e957299e739fe10d0bf55
2021-06-16 01:11:26 +00:00
Lorenzo Colitti
5f78e30839 Merge changes from topic "per-app-cts"
* changes:
  CTS tests for setOemNetworkPreference
  Update CS so that per-app OEM APIs can be tested
2021-06-16 00:47:06 +00:00
Lucas Lin
d3195fe2e7 Merge "Send a proxy broadcast when apps moved from/to a VPN" am: cfc86ef0f6 am: f7aa7c51ee am: c3b4cf2e19
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1717735

Change-Id: Icb1af8bf4ded2984d4c10385bf692d95c6d2e55d
2021-06-15 17:34:24 +00:00
Lucas Lin
c3b4cf2e19 Merge "Send a proxy broadcast when apps moved from/to a VPN" am: cfc86ef0f6 am: f7aa7c51ee
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1717735

Change-Id: I12ec4b1c5e4123c9e13219ec0e83858bf1ec09ea
2021-06-15 09:32:28 +00:00
Lucas Lin
cfc86ef0f6 Merge "Send a proxy broadcast when apps moved from/to a VPN" 2021-06-15 09:26:21 +00:00
Paul Hu
c323f6502d Merge "Add DEFAULT_NETWORK_PRIORITY constants" 2021-06-15 02:42:03 +00:00
Paul Hu
c6741064d0 Merge "Add more unit tests for mobile data preferred uids feature" 2021-06-15 01:28:19 +00:00
Treehugger Robot
bff8161a27 Merge "Fully setup test TUN iface on create." am: 6c0525fbd5 am: 4b8900e520 am: 5179e12560
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1719792

Change-Id: I5215a84c06ff08a8d90bd47654b4e63187ef9e8e
2021-06-14 20:06:55 +00:00
Treehugger Robot
5179e12560 Merge "Fully setup test TUN iface on create." am: 6c0525fbd5 am: 4b8900e520
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1719792

Change-Id: I097e46c338c978f22f48e08fbcd584ef58b95ef8
2021-06-14 19:46:44 +00:00
Treehugger Robot
6c0525fbd5 Merge "Fully setup test TUN iface on create." 2021-06-14 19:14:02 +00:00
paulhu
e99137226e Add DEFAULT_NETWORK_PRIORITY constants
- Add default network priority to NetworkRequestInfo.
- The default network priority value is used when issue uid
  ranges rules to netd. Netd will use the priority value and uid
  ranges to generate corresponding ip rules specific to the given
  network preference.

Bug: 171872461
Test: atest FrameworksNetTests
Merged-In: I0ea71b348492aeb4784d487bed4cfd5d387426ba

Change-Id: I0ea71b348492aeb4784d487bed4cfd5d387426ba
2021-06-14 15:55:55 +00:00
paulhu
01f52e7cce Add more unit tests for mobile data preferred uids feature
- Add more tests for mobile data preferred uids.
- Also address leftover comments on implementation commit.

Bug: 171872461
Test: atest FrameworksNetTests
Merged-In: I63f65bffc1b8883ddfd774222e26e629d7ea1f94

Change-Id: I63f65bffc1b8883ddfd774222e26e629d7ea1f94
2021-06-14 15:53:05 +00:00
Paul Hu
af3798b8e5 Merge "Add DEFAULT_NETWORK_PRIORITY constants" into sc-dev am: dcba997adf am: ab4b8bc600
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/14731886

Change-Id: If462f369e2cf7a74a0a5895073743e27f832ac0e
2021-06-14 15:49:38 +00:00
Paul Hu
ab4b8bc600 Merge "Add DEFAULT_NETWORK_PRIORITY constants" into sc-dev am: dcba997adf
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/14731886

Change-Id: Iabe8738dc2579bd89f6be377666c4e7a9178b1a6
2021-06-14 15:33:35 +00:00
Paul Hu
dcba997adf Merge "Add DEFAULT_NETWORK_PRIORITY constants" into sc-dev 2021-06-14 15:17:23 +00:00
Paul Hu
714af33653 Merge "Add more unit tests for mobile data preferred uids feature" into sc-dev am: 7d5fa3da7d am: fccce46a7c
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/14731884

Change-Id: I616f67b162618e7b195adf167cbaa62990c3ff50
2021-06-14 15:02:30 +00:00
Paul Hu
31c7026ff9 Merge "Add more unit tests for mobile data preferred uids feature" into sc-dev am: 7d5fa3da7d
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/14731884

Change-Id: I5a97d3caea19c51597c63319bbb8a720c7f91977
2021-06-14 14:47:46 +00:00
Paul Hu
7d5fa3da7d Merge "Add more unit tests for mobile data preferred uids feature" into sc-dev 2021-06-14 14:29:29 +00:00
Lorenzo Colitti
4b80e297e7 Merge "Correctly get uids for per-app network preferences" am: 473ddeaebb am: d9c5536026 am: 9088465b13
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1723617

Change-Id: I90636ede4f7136f475b992b0a2319fcb10e195d6
2021-06-14 06:45:17 +00:00
Lorenzo Colitti
9088465b13 Merge "Correctly get uids for per-app network preferences" am: 473ddeaebb am: d9c5536026
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1723617

Change-Id: I1b99d78702c91ce3e4c69de95e09a0c1e7d7e4b5
2021-06-14 06:32:56 +00:00
Lorenzo Colitti
473ddeaebb Merge "Correctly get uids for per-app network preferences" 2021-06-14 06:07:56 +00:00
Lorenzo Colitti
cd60e94a2c Merge changes I944f4c6a,I69cf58bc into sc-dev
* changes:
  Don't send onLinkPropertiesChanged after onLost for 464xlat.
  Improve test coverage for disconnecting networks with clat.
2021-06-14 05:51:54 +00:00
Lorenzo Colitti
beb7d92cbc 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
Original-Change: https://android-review.googlesource.com/1727829
Merged-In: I944f4c6ad36206bdccd85a6ea7ef71324a29c685
Change-Id: I944f4c6ad36206bdccd85a6ea7ef71324a29c685
2021-06-11 13:46:33 +00:00
Bill Yi
d7ec12e91d Import translations. DO NOT MERGE ANYWHERE
Auto-generated-cl: translation import
Change-Id: Ice6b9421c94bb6253595e955e9585eab2115ff61
2021-06-11 09:59:22 +00:00
paulhu
c2198778ab Add DEFAULT_NETWORK_PRIORITY constants
- Add default network priority to NetworkRequestInfo.
- The default network priority value is used when issue uid
  ranges rules to netd. Netd will use the priority value and uid
  ranges to generate corresponding ip rules specific to the given
  network preference.

Bug: 171872461
Test: atest FrameworksNetTests
Ignore-AOSP-First: Needs cherry-picks
Change-Id: I0ea71b348492aeb4784d487bed4cfd5d387426ba
2021-06-11 14:22:33 +08:00
Remi NGUYEN VAN
7a80ae85d6 Merge changes I8d15b626,I993e8da9 am: d15e52eca9 am: 3cc611d69a am: 45dd5391ed
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1733772

Change-Id: Ie41a3726bd3f90a957e2507c0c2f90c5024440e4
2021-06-11 00:19:41 +00:00
Remi NGUYEN VAN
45dd5391ed Merge changes I8d15b626,I993e8da9 am: d15e52eca9 am: 3cc611d69a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1733772

Change-Id: Ice0291696167275ae20a423b74671d252fe09fb4
2021-06-11 00:05:52 +00:00
paulhu
7ed70a944c Add more unit tests for mobile data preferred uids feature
- Add more tests for mobile data preferred uids.
- Also address leftover comments on implementation commit.

Bug: 171872461
Test: atest FrameworksNetTests
Ignore-AOSP-First: Needs cherry-picks
Change-Id: I63f65bffc1b8883ddfd774222e26e629d7ea1f94
2021-06-11 00:09:45 +08:00
Remi NGUYEN VAN
499219702b Revert "Use shell permission to query current user"
This reverts commit 95bc8d7067.

Reason for revert: Conflict with revert for b/190622577

Change-Id: I993e8da9737634d0cc815cd75b461699170602cc
2021-06-10 15:05:17 +00:00
Remi NGUYEN VAN
ee395bb629 Merge "Use shell permission to query current user" am: dbb2a23a38 am: 7252278df7 am: 62f6e19968
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1730549

Change-Id: I66d06b6217abaa55001d348cdd3ae0b0c1d89a5d
2021-06-10 06:05:00 +00:00
Remi NGUYEN VAN
62f6e19968 Merge "Use shell permission to query current user" am: dbb2a23a38 am: 7252278df7
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1730549

Change-Id: I74b82e3ff03f0bc540c5023b4a9af9799915e559
2021-06-10 05:53:29 +00:00
James Mattis
fa270db5f7 Update CS so that per-app OEM APIs can be tested
Updates to ConnectivityService so that the set OEM network preference
per app APIs can be tested via CTS.

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

Change-Id: I5a47dcece31749293f080af060218d827082eb67
2021-06-09 19:59:56 -07:00
Cody Kesting
7a5fbc2b6e Fully setup test TUN iface on create.
This CL updates TestNetworkService to fully setup test TUN
interfaces when created. Previously, the interface was only
created in netd when the Test Network was created.

Bug: 182291467
Bug: 189125789
Test: atest Ikev2VpnTest IpSecManagerTunnelTest
Change-Id: I4c1262e566517bbb03dd610f595e4d18bc4e7735
2021-06-09 11:50:53 -07:00
Remi NGUYEN VAN
95bc8d7067 Use shell permission to query current user
Use shell permissions to obtain CREATE_USERS to call
ActivityManager.getCurrentUser in ConnectivityServiceTest.

This is necessary to allow the tests to run in coverage tests without
the platform certificate.

Bug: 187935317
Test: atest FrameworksNetTests:ConnectivityServiceTest
Change-Id: I5a56ffab4820d351dcdb132046698cd0d3b8bdb1
2021-06-09 19:28:16 +09:00
Lorenzo Colitti
0730c9315c Merge "Don't send onLinkPropertiesChanged after onLost for 464xlat." am: a3f12dd52c am: b4e1b65298 am: 7d9f43c6f3
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1727829

Change-Id: I35258b459a59d39ec8606ec84bf9b345ddd07b11
2021-06-09 08:34:24 +00:00
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
Junyu Lai
07f97b249c Merge changes from topic "cts-snapshots"
* changes:
  Add CTS for NetworkAgentConfig#setSubscriberId
  Add CTS for getAllNetworkStateSnapshots
  Check NETWORK_SETTINGS permission for getAllNetworkStateSnapshots
2021-06-09 08:09:41 +00:00
Lorenzo Colitti
a3f12dd52c Merge "Don't send onLinkPropertiesChanged after onLost for 464xlat." 2021-06-09 07:59:25 +00:00
junyulai
eaaacb0d47 Check NETWORK_SETTINGS permission for getAllNetworkStateSnapshots
This is declared in the API surface, but the implementation
does not match.

Test: atest CtsNetTestCases:android.net.cts.ConnectivityManagerTest#testGetAllNetworkStateSnapshots
Bug: 188140631

Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: I97aa69651461ebe5c323ec669372f9a61b84e6a6
Change-Id: I97aa69651461ebe5c323ec669372f9a61b84e6a6
  (cherry-picked from ag/14601670)
2021-06-09 01:34:14 +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