Commit Graph

11662 Commits

Author SHA1 Message Date
Adrian Roos
14c08d26d5 API: Suppress existing NullableCollections lints
Bug: 152525509
Bug: 154763999
Test: make checkapi
Change-Id: Iecd0927e6be5496b2fbd1a49396db5439257ffe4
2021-02-01 15:04:10 +01:00
Lorenzo Colitti
e73a36ba21 Merge changes Idcc9e32c,I58769bb7
* changes:
  Remove getFilteredNetworkState and add @NonNull in NetworkState.
  Add test coverage for get*NetworkInfo on metered networks.
2021-02-01 10:56:19 +00:00
Lorenzo Colitti
6f55e61287 Remove getFilteredNetworkState and add @NonNull in NetworkState.
getFilteredNetworkState is only used in two places, both of which
use only small parts of the NetworkState that is returned to
them. Remove the method and replace it with inline code in the
two callers. NetworkState is a fairly expensive object, and this
removes the need to perform lots of defensive copies of data that
the caller does not need.

Also remove the only call to the NetworkState constructor in
ConnectivityService. That leaves only one caller to the
NetworkState constructor, the one in NetworkAgentInfo. This
constructor is called with defensive copies of NetworkInfo,
LinkProperties, and NetworkCapabilities, so mark these three
parameters as @NonNull. It's also called with a non-null
Network, because NetworkAgentInfo is only constructed with
non-null Networks, so mark the network parameter @NonNull as
well.

In order to make the arguments in the NetworkState constructor
@NonNull, introduce a new constructor that sets everything to
null and make NetworkState.EMPTY call it.

Test: atest FrameworksNetTests
Change-Id: Idcc9e32c53533b0cf61494517e62d4c184fa7610
2021-02-01 16:12:04 +09:00
Lorenzo Colitti
0e920055dc Add test coverage for get*NetworkInfo on metered networks.
Test: test-only change
Change-Id: I58769bb768978d0acff1da6d32c2f6942c43508b
2021-02-01 15:58:12 +09:00
Remi NGUYEN VAN
8f37b3f55b Move module sources to packages/Connectivity
Files that are planned to be part of the connectivity module are grouped
in packages/Connectivity, so they can be built separately and moved in
one operation with their history into packages/modules/Connectivity.

This places the files in the existing framework-connectivity-sources
filegroup instead of the current framework-core-sources filegroup. Both
are used the same way in framework-non-updatable-sources.

Bug: 171540887
Test: m
Change-Id: I62d9d91574ace6f5c4624035d190260c3126b91e
2021-02-01 11:52:14 +09:00
Junyu Lai
bc1a11fdb2 Merge "[FUI16] Expose setSubscriberId in NetworkAgentConfig as system API" 2021-01-29 17:15:28 +00:00
junyulai
6e74469a64 [FUI16] Expose setSubscriberId in NetworkAgentConfig as system API
The wifi (mainline module) need to set the subscriberId for specific
wifi network.

Bug: 176396812
Test: TreeHugger
Change-Id: Ib568ce0c2d1b629e1c20e7ac8d8b78579cf4825c
2021-01-29 22:09:10 +08:00
Junyu Lai
149add890e Merge "[FUI04] Refactor VpnInfo" 2021-01-29 13:54:53 +00:00
Junyu Lai
2141aec60a Merge "[VCN06] Support request background network" 2021-01-29 11:02:02 +00:00
junyulai
62d35f7e59 [FUI04] Refactor VpnInfo
As a preparation of exposing system API. This patch does some
harmless refactoring, which includes:
  1. Change raw arrays into lists according to API guidelines.
  2. Write test.
  3. Rename class to UnderlyingNetworkInfo.
  4. Rename vpnIface to iface.
  5. Make underlyingIfaces @NonNull in order to adapt new
     unparceling code.
  6. implement equals and hashCode for testing.

Test: atest android.net.UnderlyingNetworkInfoTest
Bug: 174123988

Change-Id: I405c21e57c4af8a12a9dd0a1749b9e6690f87045
2021-01-29 17:44:32 +08:00
Junyu Lai
23568a4f04 [VCN06] Support request background network
This will be mainly used by VCN management service which will
need to hold the networks but preserve the backgrounded-ness
of the networks.

Test: android.net.ConnectivityManagerTest#testRequestType
Test: android.net.cts.ConnectivityManagerTest#testRequestBackgroundNetwork /
      --rerun-until-failure 100
Test: ConnectivityServiceTest#testBackgroundNetworks
Test: m -j doc-comment-check-docs
Bug: 175662146

Change-Id: I463c7a3139a286e50ea71e674060975ce228caa9
2021-01-29 14:42:32 +08:00
Junyu Lai
00caf89795 Merge "[VCN01] Add NOT_VCN_MANAGED capability" 2021-01-28 13:04:59 +00:00
Treehugger Robot
a7656b2d7e Merge "Note network interfaces based on transport" 2021-01-28 07:45:20 +00:00
Lorenzo Colitti
83563fd735 Merge "Fix legacy APIs when VPN switches to suspended underlying network." 2021-01-28 07:07:37 +00:00
Chiachang Wang
f13926d8dc Merge "Replace hidden getFileDescriptor$()" 2021-01-28 06:36:11 +00:00
Remi NGUYEN VAN
afd7560b29 Note network interfaces based on transport
Instead of classifying interfaces by network type in BatteryStats,
classify them based on the transports array provided by the
NetworkAgent.

Network types are deprecated and transports should be used instead. This
change allows BatteryStats to stop depending on unstable APIs such as
isNetworkTypeMobile.

This change also updates nullability annotations in ConnectivityService
and NetworkAgentInfo to show that the NetworkCapabilities are non-null
(as provided by the network agent) when calling
noteNetworkInterfaceTransports.

Bug: 174436414
Test: atest
  atest ConnectivityServiceTest#testBatteryStatsNetworkType \
      --rerun-until-failure 40

Merged-In: I4e928fac8a57a9b1fc758a44af2a5719b8c871b8

Change-Id: I4e928fac8a57a9b1fc758a44af2a5719b8c871b8
2021-01-28 15:10:54 +09:00
Treehugger Robot
a4520fd260 Merge "[Mainline] Migrate TextUtils#emptyIfNull" 2021-01-28 06:05:08 +00:00
Lucas Lin
d1a04ba095 Merge "Use createStringArray instead of readStringArray" 2021-01-28 04:04:10 +00:00
lucaslin
cee4354c1d Use createStringArray instead of readStringArray
To prevent ProxyInfo calling hidden API, use public one -
Parcel#createStringArray() instead.

Bug: 170598012
Test: atest FrameworksNetTests
Change-Id: I1a5376872d743e1863982bb95d579aeba7159d33
2021-01-28 04:03:59 +00:00
Lucas Lin
d15fcc3048 Merge "Check if NetworkSpecifier is an instance of MatchAllNetworkSpecifier" 2021-01-28 04:01:49 +00:00
Chiachang Wang
0bb339732d Replace hidden getFileDescriptor$()
It's the preparation for the incoming ConnectivityService
mainline. The mainline modules can not access hidden APIs.
Thus, the hidden APIs usage should be removed.

The getFileDescriptor$() in Socket or DatagramSocket is
hidden for internal usage. It should be used in a module and
not prefer to expose as an API. Thus, replace it with
ParcelFileDescriptor APIs to get the fd via
ParcelFileDescriptor.

Bug: 170598012
Test: atest FrameworksNetTests
Change-Id: I05b31a48315e7e6d95e22123103e544a7136a449
2021-01-28 11:33:13 +08:00
Treehugger Robot
c1140f2a33 Merge "[FUI03] No-op refactoring of VpnInfo" 2021-01-27 11:47:34 +00:00
Junyu Lai
120e49e971 [VCN01] Add NOT_VCN_MANAGED capability
Add new capability to indicate whether a network is
managed by Virtual Carrier Network (VCN). This is needed
to identify networks between VCN managed network and
others. And this capability will be:
  1. mutable
  2. requestable
  3. set by default for network agents and requests
  4. allowed for test networks

Note that this commit is identical to aosp/1529959 except the
capability remains hidden to address the javadoc problem first.
And this CL also needs to be bound with the counter part change
to prevent build breakage.

Test: 1. atest FrameworksNetTests CtsNetTestCases
      2. adb shell dumpsys connectivity
      3. atest ConnectivityServiceTest#testLoseMutableAndRequestableCaps
Bug: 175662146

Change-Id: I37a6f492c2aba72836e36851b50b67398f8bdd36
2021-01-27 16:13:01 +08:00
lucaslin
61ad5f342e Check if NetworkSpecifier is an instance of MatchAllNetworkSpecifier
To prevent mainline module related file to access a hidden API,
check whether the NetworkSpecifier is an instance of
MatchAllNetworkSpecifier by itself.

Bug: 172183305
Test: atest FrameworksNetTests
Change-Id: I4d49cb70ff3c8a7e1ffa32e38207c74a6375e51a
2021-01-27 15:32:43 +08:00
Remi NGUYEN VAN
82a30b6bbe Merge "Move connectivity-sources to frameworks/base" 2021-01-27 07:15:05 +00:00
junyulai
bd7f3cd75b [FUI03] No-op refactoring of VpnInfo
As a preparation of exposing system API. This patch does some
harmless refactoring, which includes:
  1. Move VpnInfo to android.net
  2. Add nullability annotations
  3. Make members final

Bug: 174123988
Test: TH
Change-Id: I1530bb45d0e84c28c6deac33596bc686058afc0d
2021-01-27 15:03:06 +08:00
James Mattis
4c69988898 Merge changes Ic67cff95,Id7a6175c,I3d6896f5,Iaff727e7
* changes:
  Updates to handler logic for multilayer requests
  Update to sendAllRequestsToProvider for Multilayer
  Multilayer request updates to request callbacks
  Multilayer support when NAI requests are updated
2021-01-27 04:50:43 +00:00
James Mattis
08131f3446 Updates to handler logic for multilayer requests
Updates to ConnectivityService network request handler's logic to support
(or disallow support of) multilayer network requests.

Bug: 175239920
Bug: 171991028
Test: atest FrameworksNetTests
atest NetworkStackTests
atest FrameworksNetIntegrationTests
atest NetworkStackIntegrationTests
atest CtsNetTestCasesLatestSdk

Change-Id: Ic67cff950d72745d6508a0a037bd33f932d5132c
2021-01-26 18:44:45 -08:00
James Mattis
7b26bba8de Update to sendAllRequestsToProvider for Multilayer
Updates to ConnectivityService.sendAllRequestsToProvider to support
Multilayer requests.

Bug: 175051182
Bug: 171991028
Test: atest FrameworksNetTests
atest FrameworksNetIntegrationTests
atest CtsNetTestCasesLatestSdk

Change-Id: Id7a6175cee28d2de1f6194cd0fc8c739d667427d
2021-01-26 18:44:32 -08:00
Chiachang Wang
332aae3a6e Merge "Update jni to get int descriptor in native layer" 2021-01-27 02:44:29 +00:00
Chiachang Wang
30199ca9f8 Update jni to get int descriptor in native layer
ConnectivityService is going to become a mainline module which
can not access the hidden APIs. The int descriptor of a
FileDescriptor is hidden for internal use only. The Network and
NetworkUtls will be parts of CS module. The corresponding usage
should be removed. There is no way in a module to access the
descriptor, so update the jni to set a FileDescriptor to native
to get the int descriptor inside the platform.

Also, update the other references in android_net_NetUtils for
getting fd to use the NDK functions in the libnativehelper.

Bug: 170598012
Test: atest FrameworksNetTests CtsNetTestCasesLatestSdk
Test: manually connect to a VPN
Change-Id: I2143c079feac53917a6e7bf7422f3180f51437fb
2021-01-27 02:44:14 +00:00
Paul Hu
4071a8ccb1 Merge "Fix FrameworksNetIntegrationTests failure" 2021-01-27 00:04:09 +00:00
Paul Hu
d07d47e255 Merge "Revert^2 "Replace Context#sendStickyBroadcastAsUser()"" 2021-01-27 00:04:09 +00:00
James Mattis
757e0e8b3e Multilayer request updates to request callbacks
Updated to ConnectivityService to support multilayer requests when
sending request level callbacks.

Bug: 174797702
Bug: 171991028
Test: atest FrameworksNetTests
atest NetworkStackTests
atest FrameworksNetIntegrationTests
atest NetworkStackIntegrationTests
atest CtsNetTestCasesLatestSdk

Change-Id: I3d6896f5705509bcfff5544d2eb13c31feaf1937
2021-01-26 12:33:43 -08:00
James Mattis
622428ceea Multilayer support when NAI requests are updated
Updates to ConnectivityService to support multilayer requests in any
flows which a NetworkAgentInfo has a NetworkRequest added/removed. This
would include both 'listen' and 'request' types of NetworkRequest
objects.

Bug: 174271773
Bug: 171991028
Test: atest FrameworksNetTests
atest NetworkStackTests
atest FrameworksNetIntegrationTests
atest NetworkStackIntegrationTests
atest CtsNetTestCasesLatestSdk

Change-Id: Iaff727e792828684e6ad4d07d0081e27992031be
2021-01-26 12:33:37 -08:00
Treehugger Robot
c5a7a59483 Merge changes I713bc2ec,Ib9ab07c9
* changes:
  [FUI05] Remove wimax data usage unit test
  [FUI14] Get SSID from NetworkCapabilities
2021-01-26 13:13:24 +00:00
Paul Hu
32fd208a71 Revert^2 "Replace Context#sendStickyBroadcastAsUser()"
ConnectivityService is using Context#sendStickyBroadcastAsUser
to send sticky broadcast but this API is not able to call after
it becomes part of Connectivity mainline module. Thus, replace it
with Context#sendStickyBroadcast.

The original commit was reverted because of a test failure. This
reverted commit is bound to the fix and will submit together.

Bug: 177223402
Change-Id: I75b8494e8ee30f484f33e9a9a660c7f9ad75f368
Test: atest FrameworksNetTests
Test: atest CtsNetTestCases
Test: atest CtsNetApi23TestCases
Test: atest FrameworksNetIntegrationTests
2021-01-26 02:53:06 +00:00
Daniel Bright
591fe5327c Merge "Add method to match address \ port with QosFilter" 2021-01-25 18:03:32 +00:00
Will Osborn
42a9366c6f Merge "Revert "Replace Context#sendStickyBroadcastAsUser()"" 2021-01-25 17:20:29 +00:00
paulhu
b15a22e5b9 Fix FrameworksNetIntegrationTests failure
The test is broken because CS is using
sendStickyBroadcast with all users context instead of
sendStickyBroadcastAsUser to send sticky broadcast. So update
related code on ConnectivityServiceIntegrationTest.

Bug: 178367782
Test: atest FrameworksNetIntegrationTests
      atest FrameworksNetTests
Change-Id: I7ad94fa31ea16025e6ad62d41235978f45be5d99
2021-01-25 23:40:06 +08:00
Will Osborn
3eaba31d42 Revert "Replace Context#sendStickyBroadcastAsUser()"
This reverts commit c529710329.

Reason for revert: DroidMonitor: Potential culprit for Bug http://b/178367782 - verifying through Forrest before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.

Change-Id: I7fd74bf481febf1cba8b6c8fbf01c4908f847606
2021-01-25 14:34:30 +00:00
Paul Hu
0a6682146c Merge "Replace Context#sendStickyBroadcastAsUser()" 2021-01-25 05:57:22 +00:00
Remi NGUYEN VAN
c2fb349511 Move connectivity-sources to frameworks/base
All sources for the connectivity module are being moved to
frameworks/base/packages/Connectivity, so that they can all be moved to
packages/modules/Connectivity in one move keeping history.

INetworkAgent and INetworkAgentRegistry were created in
packages/modules/Connectivity directly, but this makes managing the
sources until the move harder as the module needs to pull sources from
two different locations. Considering that they do not have history to
move, just move them to frameworks/base/packages/Connectivity without
the commit history.

Bug: 171540887
Test: m
Change-Id: Ic4353115a98b6235c2b5d5ce24741223e618d0a6
2021-01-25 11:47:42 +09:00
junyulai
cb95247c1e [FUI05] Remove wimax data usage unit test
In follow-up patches, the network type will be derived from
transport types, which officially doesn't support wimax.
Thus, remove the test which rely on it first since it is
not needed and will not be needed.

Test: atest FrameworksNetTests
Bug: 174123988
Change-Id: I713bc2ec39e3a4fa19ed13d2e9ff9ae35477d726
2021-01-22 23:58:14 +08:00
junyulai
de493c006a [FUI14] Get SSID from NetworkCapabilities
This allows subsequent patches to remove the need of exposing
SSID in NetworkState.

Test: atest NetworkStatsServiceTest
Bug: 174123988
Change-Id: Ib9ab07c9610954c9a5de035a3aefbf6d0bb0b53b
2021-01-22 23:58:14 +08:00
Daniel Bright
07dd129bbe Add method to match address \ port with QosFilter
* The match method is only for local address and port since we have
no other use case.

Bug: 155176305
Test: Added new test
Change-Id: I7b45f9912af6a192fc60606f5e0b4cc479aea93f
2021-01-22 06:24:41 -08:00
Paul Hu
85aad57203 Merge "Replace NetworkPolicyManagerInternal#isUidRestrictedOnMeteredNetworks()" 2021-01-22 14:18:47 +00:00
Chalard Jean
29f0f6d47f Merge "Add Qos Callback support" 2021-01-22 13:09:24 +00:00
Chalard Jean
a96f7a4d89 Merge "Add Qos Callback files" 2021-01-22 13:06:43 +00:00
Remi NGUYEN VAN
5ef8031d57 Merge "Mark connectivity test utilities as module API" 2021-01-22 10:11:39 +00:00