Commit graph android_packages_modules_Co.../service/src/com/android/server
Message SHA1
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: I1e264659c1cd6d88a669524af8ceacb5c6c05105

Remi NGUYEN VAN   authored and   Automerger Merge Worker   commited 2021-06-16 11:38:00 +00:00
a08680a505
Merge "Remove ConnectivityServiceTest signature perms use"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2021-06-16 11:09:05 +00:00
54c7434f0d
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

Remi NGUYEN VAN   commited 2021-06-16 16:32:03 +09:00
18a979fa41
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: I1b13784797d2b1326d4ae31d813cc6332101c532

James Mattis   authored and   Automerger Merge Worker   commited 2021-06-16 01:29:56 +00:00
73bdd21f0a
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

James Mattis   authored and   Automerger Merge Worker   commited 2021-06-16 01:11:26 +00:00
6c54d5e4c4
Merge changes from topic "per-app-cts"
* changes:
  CTS tests for setOemNetworkPreference
  Update CS so that per-app OEM APIs can be tested

Lorenzo Colitti   authored and   Gerrit Code Review   commited 2021-06-16 00:47:06 +00:00
5f78e30839
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: Ie3837b6561ccbd99088fba758f792596a66e71e2

Lucas Lin   authored and   Automerger Merge Worker   commited 2021-06-15 09:32:42 +00:00
655a025198
Merge "Send a proxy broadcast when apps moved from/to a VPN"
Lucas Lin   authored and   Gerrit Code Review   commited 2021-06-15 09:26:21 +00:00
cfc86ef0f6
Merge "Add DEFAULT_NETWORK_PRIORITY constants"
Paul Hu   authored and   Gerrit Code Review   commited 2021-06-15 02:42:03 +00:00
c323f6502d
Merge "Add more unit tests for mobile data preferred uids feature"
Paul Hu   authored and   Gerrit Code Review   commited 2021-06-15 01:28:19 +00:00
c6741064d0
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: Icdd513a903745b35e2418bbea6d89d7f3b47e022

Treehugger Robot   authored and   Automerger Merge Worker   commited 2021-06-14 19:46:45 +00:00
15a93b3573
Merge "Fully setup test TUN iface on create."
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-06-14 19:14:02 +00:00
6c0525fbd5
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

paulhu   commited 2021-06-14 15:55:55 +00:00
e99137226e
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

paulhu   commited 2021-06-14 15:53:05 +00:00
01f52e7cce
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: I54aa207ba6a49ef576021d7e703b6bed778ef814

Paul Hu   authored and   Automerger Merge Worker   commited 2021-06-14 15:33:48 +00:00
d56d7cf880
Merge "Add DEFAULT_NETWORK_PRIORITY constants" into sc-dev
Paul Hu   authored and   Android (Google) Code Review   commited 2021-06-14 15:17:23 +00:00
dcba997adf
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: If434ff9d82c2951376377f8ef78720a5b80f56af

Paul Hu   authored and   Automerger Merge Worker   commited 2021-06-14 14:47:45 +00:00
6b8b5c3da1
Merge "Add more unit tests for mobile data preferred uids feature" into sc-dev
Paul Hu   authored and   Android (Google) Code Review   commited 2021-06-14 14:29:29 +00:00
7d5fa3da7d
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: Iaf413208ba0ac560b13f102e8a2308866b97dd3a

Lorenzo Colitti   authored and   Automerger Merge Worker   commited 2021-06-14 06:33:04 +00:00
8bd2cb97da
Merge "Correctly get uids for per-app network preferences"
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2021-06-14 06:07:56 +00:00
473ddeaebb
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

Lorenzo Colitti   commited 2021-06-11 13:46:33 +00:00
beb7d92cbc
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

paulhu   commited 2021-06-11 14:22:33 +08:00
c2198778ab
Merge changes I8d15b626,I993e8da9 am: d15e52eca9 am: 3cc611d69a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1733772

Change-Id: I05bc411729d9960d580ccbfcee8502ec5eba3d97

Remi NGUYEN VAN   authored and   Automerger Merge Worker   commited 2021-06-11 00:04:42 +00:00
8cc60e436c
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

paulhu   commited 2021-06-11 00:09:45 +08:00
7ed70a944c
Revert "Use shell permission to query current user"
This reverts commit 95bc8d7067.

Reason for revert: Conflict with revert for b/190622577

Change-Id: I993e8da9737634d0cc815cd75b461699170602cc

Remi NGUYEN VAN   commited 2021-06-10 15:05:17 +00:00
499219702b
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: I7305bb57bc7218f2dd110a02324649287faed007

Remi NGUYEN VAN   authored and   Automerger Merge Worker   commited 2021-06-10 05:54:11 +00:00
14d6e26112
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

James Mattis   commited 2021-06-09 19:59:56 -07:00
fa270db5f7
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

Cody Kesting   commited 2021-06-09 11:50:53 -07:00
7a5fbc2b6e
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

Remi NGUYEN VAN   commited 2021-06-09 19:28:16 +09:00
95bc8d7067
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: Ifbdf8908508c3bcb3387562d602cde9b3f1c2b9f

Lorenzo Colitti   authored and   Automerger Merge Worker   commited 2021-06-09 08:34:14 +00:00
52cef7c369
Merge changes from topic "cts-snapshots"
* changes:
  Add CTS for NetworkAgentConfig#setSubscriberId
  Add CTS for getAllNetworkStateSnapshots
  Check NETWORK_SETTINGS permission for getAllNetworkStateSnapshots

Junyu Lai   authored and   Gerrit Code Review   commited 2021-06-09 08:09:41 +00:00
07f97b249c
Merge "Don't send onLinkPropertiesChanged after onLost for 464xlat."
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2021-06-09 07:59:25 +00:00
a3f12dd52c
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)

junyulai   authored and   Junyu Lai   commited 2021-06-09 01:34:14 +00:00
eaaacb0d47
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

Junyu Lai   authored and   Gerrit Code Review   commited 2021-06-08 22:34:44 +00:00
5b15e700bb
Merge "Move UIDS_ALLOWED_ON_RESTRICTED_NETWORKS setting"
Paul Hu   authored and   Gerrit Code Review   commited 2021-06-08 07:23:39 +00:00
7cba5f4163
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

Lorenzo Colitti   commited 2021-06-08 15:48:57 +09:00
b4bf015b57
Merge "Address leftover comments"
Paul Hu   authored and   Gerrit Code Review   commited 2021-06-08 06:18:19 +00:00
e2791b00d3
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)

Chalard Jean   authored and   Junyu Lai   commited 2021-06-08 00:17:38 +00:00
f4c48a4d5f
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)

Chalard Jean   authored and   Junyu Lai   commited 2021-06-08 00:17:37 +00:00
550b5214d3
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)

junyulai   authored and   Junyu Lai   commited 2021-06-08 00:17:37 +00:00
36c02987c6
[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)

Chalard Jean   authored and   Junyu Lai   commited 2021-06-08 00:17:37 +00:00
c81d4c3c7e
Use filter from CollectionUtils.
Test: ConnectivityServiceTest
Fixes: 184826320
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: Iae8df6058c0a43fba1e6ebcd6003df54751f9646
Change-Id: Iae8df6058c0a43fba1e6ebcd6003df54751f9646
  (cherry-picked from ag/14125157)

Chalard Jean   authored and   Junyu Lai   commited 2021-06-08 00:17:36 +00:00
5e8f8431d8
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)

Chalard Jean   authored and   Junyu Lai   commited 2021-06-08 00:17:36 +00:00
9f6d447a42
[NS12] Address comments on NS09
Test: ConnectivityServiceTest
Fixes: 184507247
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: Ic4500dc85507fa68538c9ec179ec6eb4f44c5022
Change-Id: Ic4500dc85507fa68538c9ec179ec6eb4f44c5022
  (cherry-picked from ag/14091168)

Chalard Jean   authored and   Junyu Lai   commited 2021-06-08 00:17:36 +00:00
29cb06a3e0
[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)

Chalard Jean   authored and   Junyu Lai   commited 2021-06-08 00:17:36 +00:00
142f0fe4d4
Require location permission for ConnDiags WiFi only.
This CL updates ConnectivityDiagnostics permission checks in
ConnectivityService to only require location permission for Networks
that have TRANSPORT_WIFI. This change is consistent with the location
restrictions required for the transports themselves. Previously,
location permissions were required for all Network types.

Bug: 187310575
Test: atest ConnectivityServiceTest ConnectivityDiagnosticsManagerTest
Change-Id: I48806533e4e705d2d9be45f3b3d3931d9294b167
Merged-In: I48806533e4e705d2d9be45f3b3d3931d9294b167
(cherry picked from commit 0990af5148)

Treehugger Robot   authored and   Cody Kesting   commited 2021-06-07 22:17:05 +00:00
27b6888364
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: I29c3b93b2b4ec9cd218ecd9b0c14f90031a1dec4

Treehugger Robot   authored and   Automerger Merge Worker   commited 2021-06-07 19:23:01 +00:00
6ab1beac6f
Merge "[NS10] Fix a bug where registerIgnoringScore is broken"
Junyu Lai   authored and   Gerrit Code Review   commited 2021-06-07 18:53:37 +00:00
217f4ad9b1
Merge "Require location permission for ConnDiags WiFi only."
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-06-07 18:44:48 +00:00
5cfbc2e4cc
Send a proxy broadcast when apps moved from/to a VPN
When the apps moved from/to a VPN, a proxy broadcast is needed to
inform the apps that the proxy might be changed since the default
network satisfied by the apps might also changed.
Since the framework does not track the defautlt network of every
apps, thus, this is done when:
  1. VPN connects/disconnects.
  2. List of uids that apply to the VPN has changed.
While 1 is already covered by the current design, the CL implements
2 in order to fulfill the case that different networks have
different proxies.

Bug: 178727215
Test: atest FrameworksNetTests
Change-Id: Ifa103dd66394026d752b407a1bee740c9fcdad2b

lucaslin   commited 2021-06-08 01:43:59 +08:00
53e8a267ab