Commit graph android_packages_modules_Co.../core/java
Message SHA1
[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

junyulai   commited 2021-01-29 17:44:32 +08:00
2050bed66e
[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

junyulai   commited 2021-01-27 15:03:06 +08:00
acb3297bd0
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

Chiachang Wang   commited 2021-01-27 02:44:14 +00:00
3f7f79e658
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

Daniel Bright   commited 2021-01-22 06:24:41 -08:00
e8b27cc9d8
Merge "Add Qos Callback support"
Chalard Jean   authored and   Gerrit Code Review   commited 2021-01-22 13:09:24 +00:00
77cfa2a6ad
Mark connectivity test utilities as module API
The API surface is planned to move to the Connectivity module, meaning
that it will be maintained across multiple Android releases.
This is incompatible with TestApi semantics, which are designed to be
removable across releases. Effectively the APIs become SystemApi, so
mark them as such considering that TestApi is not supported by modules.

Remove the NetworkCapabilities.getCapabilities test API that is not
essential for tests, and mark other APIs as module API.

Test: m
Bug: 174436414
Change-Id: Ic04551a9874b3d756cf5e6c77ceabfc7c85d52a6

Remi NGUYEN VAN   commited 2021-01-22 16:16:57 +09:00
761c7ad923
Add Qos Callback support
* Provide App Developers Qos related info associated to
  a bound socket through ConnectivityManager
* Qos sessions are generated and filtered by Network Agents
  and sent back through the Connectivity Service to the
  API consumer.
* The structure of the code within com.android.server
  is designed to support different types of filters in the
  the future.
* The first type of Qos Attributes are related to EPS
  Bearers in order support RCS.

Bug: 155176305
Test: Added to cts/NetworkAgentTest
Test: Added to ConnectivityServiceTest
Change-Id: I145dd065d9deeee449eb9695ab3f6c8556ee7c09

Daniel Bright   commited 2021-01-21 20:14:52 -08:00
f9e945b074
Use network list in UNDERLYING_NETWORKS_CHANGED
The bundle is no longer necessary, as this message is not sent across
processes: the network list can be sent directly in the message obj
pair.

Bug: 173574274
Test: atest FrameworksNetTests CtsNetTestCasesLatestSdk
Change-Id: Iae049a24212ff9df19b29aead20bf4a594f05f99

Remi NGUYEN VAN   authored and   Chalard Jean   commited 2021-01-21 22:36:54 +09:00
28d69fc2f7
Use ParcelFileDescriptor instead of FileDescriptor in the aidl
Using FileDescriptor in the aidl will refer to
Parcel.readRawFileDescriptor() and Parcel.writeRawFileDescriptor()
whilie trying to do parcel operations. Those two APIs are hidden
and not accessible for the incoming ConnectivityService mainline
module. For such use cases in a module, it should be replaced by
using ParcelFileDescriptor that is designed for such usages.

Bug: 170598012
Test: atest FrameworksNetTests CtsNetTestCasesLatestSdk
Change-Id: Ia7e3a71ccb4b136cc55c9e90a384870c32cfd37b

Chiachang Wang   commited 2021-01-21 08:40:12 +00:00
04a34b647d
Merge "Replace Context @hide API in MultinetworkPolicyTracker"
Paul Hu   authored and   Gerrit Code Review   commited 2021-01-21 07:53:19 +00:00
330798dd58
Merge "Mark TestNetworkManager as module API"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2021-01-21 06:02:25 +00:00
aa8c3fd4b1
Mark TestNetworkManager as module API
The API surface is planned to move to the Connectivity module, meaning
that it will be maintained across multiple Android releases.
This is incompatible with TestApi semantics, which are designed to be
removable across releases. Effectively the APIs become System/module
API, so mark them as such considering that TestApi is not supported by
modules.

Test: m
Bug: 174436414
Change-Id: Icd32fcbb65e9a4bb2b67cb9da7c971281be0781a

Remi NGUYEN VAN   commited 2021-01-21 10:45:04 +09:00
3c6ae335c1
Replace Context @hide API in MultinetworkPolicyTracker
MultinetworkPolicyTracker is part of Connectivity mainline module
which cannot call @hide API Context#registerReceiverAsUser. Thus,
replace it to Context#registerReceiverForAllUsers.

Bug: 170634463
Test: atest FrameworksNetTests
Test: Manully check that receiving intent and unregistering
      receiver can work normally.
Change-Id: Ie22a3aa40bc9243082672a64dba7c7940f9ff21a

paulhu   commited 2021-01-21 01:19:09 +08:00
54fdd61d0c
Merge "Revert "[VCN06] Support request background network""
Junyu Lai   authored and   Gerrit Code Review   commited 2021-01-19 10:24:47 +00:00
bf49c1948a
Revert "[VCN06] Support request background network"
Revert submission 1545847-vcn06

Reason for revert: b/177876289 presubmit failure
Reverted Changes:
I8042ce197:[VCN06.1] Add CTS for request background network
If9aaa87b7:[VCN06] Support request background network

Change-Id: I9270b02a2d6d1ffcdd83b4f41becaf09a2b91e0a

Junyu Lai   commited 2021-01-19 09:06:00 +00:00
dfb7780384
Merge "[VCN06] Support request background network"
Junyu Lai   authored and   Gerrit Code Review   commited 2021-01-19 01:04:20 +00:00
f5fdc60511
[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: If9aaa87b7e71c2b695ac7b08858850e975b28bb6

junyulai   commited 2021-01-18 16:32:08 +08:00
75daea17c8
Merge "Replace hidden ParcelFileDescriptor constructor usage"
Chiachang Wang   authored and   Gerrit Code Review   commited 2021-01-18 01:59:10 +00:00
b1a007e35c
Replace hidden ParcelFileDescriptor constructor usage
If IOException happens while trying to start keepalives sockets,
an invalid fd will be constructed. It will fail with
ERROR_INVALID_SOCKET if the user later calls start(). Current
design to construct the invalid fd use the hidden
ParcelFileDescriptor constructor which will not work for the
incoming ConnectivityService mainline. Thus, replace it with
the other formal API.

Bug: 170598012
Test: atest FrameworksNetTests
Change-Id: I57fd7ec2281c5e8c75481200bbde723ecf96982a

Chiachang Wang   commited 2021-01-18 01:58:49 +00:00
619319a3f5
Merge "NetworkCapabilities: Embed location senstive TransportInfo"
Roshan Pius   authored and   Gerrit Code Review   commited 2021-01-14 15:38:15 +00:00
d0cb8f3ec3
Merge "Migrate Slog usage in MultinetworkPolicyTracker to Log"
Aaron Huang   authored and   Gerrit Code Review   commited 2021-01-14 09:10:17 +00:00
38f1711f80
Merge "[VCN05] Pass request type when requesting network"
Junyu Lai   authored and   Gerrit Code Review   commited 2021-01-14 06:52:46 +00:00
2909e18901
Migrate Slog usage in MultinetworkPolicyTracker to Log
Connectivity mainline module cannot use hidden API so
replace Slog with Log which is a public API.

Test: FrameworksNetTests
Change-Id: I8758079cf635ff4ab218df53c0f7bf6fc23ce476

Aaron Huang   commited 2021-01-14 09:53:38 +08:00
528c13e72f
Merge "Rename PacManager to PacProxyInstaller"
Aaron Huang   authored and   Gerrit Code Review   commited 2021-01-14 01:52:24 +00:00
65e963c224
Merge "Revert "[VCN01] Add NOT_VCN_MANAGED capability""
satayev   authored and   Gerrit Code Review   commited 2021-01-13 17:40:03 +00:00
66bf5f05e1
Revert "[VCN01] Add NOT_VCN_MANAGED capability"
This reverts commit d0617de32c.

Reason for revert: b/177411288 broken test

Bug: 177411288
Bug: 175662146
Change-Id: I02a25b83e62ab9a2ed22a98530d62b08de73f56e

satayev   commited 2021-01-13 15:04:23 +00:00
31a436c6d8
Rename PacManager to PacProxyInstaller
Generally, a manager class in Android is used to access
system services and it should be obtained from Context.
This class is a bit different from the definition of a
manager class.

API linter will detect an error if trying to expose a
class name end with Manager. ProxyTracker will create a
new instance of this class so this class needs to be
renamed to avoid API lint error.

Bug: 177035719
Test: FrameworksNetTests
Change-Id: I9185d4fb4342bd285a575f0bdd3518b758f37eb6

Aaron Huang   commited 2021-01-13 15:47:45 +08:00
cc52502b3c
Align coding style of line-wrapping in NetworkCapabilities
Test: TH
Change-Id: Ic864524a60954f8dbcce265643c2cb3ac3aefca8

junyulai   authored and   Junyu Lai   commited 2021-01-13 07:45:18 +00:00
fd20e05e1d
[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

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

Change-Id: Ia5eeb3912a687164fa95d7ba5516fd73abca79ba

junyulai   commited 2021-01-13 11:05:40 +08:00
d0617de32c
NetworkCapabilities: Embed location senstive TransportInfo
Changes:
i) Add a new constructor for NetworkCapabilities which accepts whether
location sensitive fields need to be parceled or not. Defalts to false
on the other constructor. This boolean should only be set on the copy of
NetworkCapabilities when sent to apps that hold location permission.
(Similar to how sensitive fields are handled in LinkProperties)
ii) Add a new makeCopy() method in the TransportInfo interface which
accepts whether location sensitive fields need to be parceled or not.
iii) Migrate the existing NetworkCapabilities owner UID masking to use
this new mechanism (instead of existing masking in ConnectivityService).
iv) Always set parcelLocationSensitiveFields to true in the NetworkAgent
surface (since that is a privileged surface from the transports to the
connectivity service)
v) Add a hasSensitiveFields() in TransportInfo interface to avoid
perfoming location permission checks for location insensitive
TrasnsportInfo.

Also, migrate to the new SdkLevel util for isAtLeastR() & isAtLeastS()
checks.

Bug: 162602799
Test: atest android.net
Test: atest com.android.server
Change-Id: Ie522d8c75a82ae521ccfd5165823d0c72642e651
Merged-In: Ie522d8c75a82ae521ccfd5165823d0c72642e651

Roshan Pius   commited 2021-01-13 02:25:49 +00:00
9ed1462e82
Merge "Support for Venue URL and friendly name from Network agent"
Hai Shalom   authored and   Gerrit Code Review   commited 2021-01-13 01:54:05 +00:00
2208ba1089
Merge "Keep Vehicle internal network always up"
Tomasz Wasilczyk   authored and   Gerrit Code Review   commited 2021-01-12 22:40:50 +00:00
2d9d5b806e
Keep Vehicle internal network always up
Bug: 171801262
Test: Boot with and without overlay set and check ifconfig
Change-Id: I1fd332caf3e09924abcfec9c2c137363be7873e4

Tomasz Wasilczyk   commited 2021-01-12 10:33:38 -08:00
54605b8501
[VCN05] Pass request type when requesting network
Currently, ConnectivityService decides the request type by
whether NetworkCapabilities is null when handling request
network. However, to fulfill the need of firing background
request via ConnectivityManager in the follow-up patches,
the request type is needed to pass into ConnectivityService.

This change also make ConnectivityService utilizes the passed
request type.

Test: atest ConnectivityManagerTest#testRequestType
Bug: 175662146
Change-Id: I3bc172bca1217c8020db45057a621d0745d43b3c

junyulai   commited 2021-01-12 19:55:00 +08:00
ad0107998f
Merge "[VCN02] Make LingerTimer takes request Id instead of NetworkRequest"
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-01-12 08:59:04 +00:00
4f5abd7cec
Support for Venue URL and friendly name from Network agent
Extend CaptivePortalData with a member to hold the venue friendly
name. If CaptivePortalData is initialized by both the network
agent and Capport, merge the two objects to include the venue
friendly name and prioritize the venue URL from the network
agent.

Bug: 162783305
Test: atest ConnectivityServiceTest
Test: atest CtsNetTestCasesLatestSdk:CaptivePortalDataTest
Test: End-to-end test
Change-Id: I4fdf356be42237c5b6c0ae5bacfd3cec4726861b

Hai Shalom   commited 2021-01-11 18:45:34 -08:00
e58bdc6fd0
Revert "wifi: Add systemAPi:setSubscriberId in NetworkAgentConfig"
This reverts commit a37dda6024.

Reason for revert: After discussion, we prefer to add a field in NetworkCapabilities instead. Sorry for inconvenience.

Change-Id: I2e8840a797df9d1594f2b8b576bcd45beb184fca

Junyu Lai   authored and   junyulai   commited 2021-01-08 19:22:28 +08:00
777533d32b
Merge "wifi: Add systemAPi:setSubscriberId in NetworkAgentConfig"
Les Lee   authored and   Gerrit Code Review   commited 2021-01-08 00:54:51 +00:00
06dbf611af
Inform ConnectivityService about always-on VPN lockdown.
Currently, when an always-on VPN is set in lockdown mode, Vpn
configures prohibit UID rules in netd directly and does not
inform ConnectivityService of the fact.

This means that ConnectivityService cannot send NetworkCallbacks
that tells apps that they are blocked or unblocked. It also means
that ConnectivityService has to take the mVpns lock and call into
Vpn to allow synchronous APIs such as getActiveNetwork to return
BLOCKED if the app is blocked.

Move all this to ConnectivityService:
- Add a setRequireVpnForUids API to ConnectivityManager, and have
  that pass the routing rules to netd.
- Update VpnTest to expect calls to ConnectivityManager instead
  of to netd.
- Whenever setRequireVpnForUids is called, ensure that
  ConnectivityService sends onBlockedStatusChanged to the
  affected callbacks.
- Update existing unit tests to check for callbacks.
- Add a way to find the VPN that applies to a given UID without
  taking the VPN lock, by instead scanning all connected VPNs.
  Use this as a replacement for direct access to mVpns.

For simplicity, and in order to ensure proper ordering between
the NetworkCallbacks sent for VPNs connecting and disconnecting,
process blocked UID ranges on the handler thread. This means that
when setRequireVpnForUids returns, the rule changes might not
have been applied. This shouldn't impact apps using network
connectivity, but it might mean that apps setting an always-on
package, and then immediately checking whether networking is
blocked, will see a behaviour change.

Bug: 173331190
Fix: 175670887
Test: new test coverage in ConnectivityServiceTest
Test: atest MixedDeviceOwnerTest#testAlwaysOnVpn \
            MixedDeviceOwnerTest#testAlwaysOnVpnLockDown \
	    MixedDeviceOwnerTest#testAlwaysOnVpnAcrossReboot \
	    MixedDeviceOwnerTest#testAlwaysOnVpnPackageUninstalled \
	    MixedDeviceOwnerTest#testAlwaysOnVpnUnsupportedPackage \
	    MixedDeviceOwnerTest#testAlwaysOnVpnUnsupportedPackageReplaced \
	    MixedDeviceOwnerTest#testAlwaysOnVpnPackageLogged \
            MixedProfileOwnerTest#testAlwaysOnVpn \
            MixedProfileOwnerTest#testAlwaysOnVpnLockDown \
	    MixedProfileOwnerTest#testAlwaysOnVpnAcrossReboot \
	    MixedProfileOwnerTest#testAlwaysOnVpnPackageUninstalled \
	    MixedProfileOwnerTest#testAlwaysOnVpnUnsupportedPackage \
	    MixedProfileOwnerTest#testAlwaysOnVpnUnsupportedPackageReplaced \
	    MixedProfileOwnerTest#testAlwaysOnVpnPackageLogged \
            MixedManagedProfileOwnerTest#testAlwaysOnVpn \
            MixedManagedProfileOwnerTest#testAlwaysOnVpnLockDown \
	    MixedManagedProfileOwnerTest#testAlwaysOnVpnAcrossReboot \
	    MixedManagedProfileOwnerTest#testAlwaysOnVpnPackageUninstalled \
	    MixedManagedProfileOwnerTest#testAlwaysOnVpnUnsupportedPackage \
	    MixedManagedProfileOwnerTest#testAlwaysOnVpnUnsupportedPackageReplaced \
	    MixedManagedProfileOwnerTest#testAlwaysOnVpnPackageLogged
Test: atest FrameworksNetTests HostsideVpnTests \
            CtsNetTestCases:VpnServiceTest \
	    CtsNetTestCases:Ikev2VpnTest
Change-Id: Iaca8a7cc343aef52706cff62a7735f338cb1b772

Lorenzo Colitti   commited 2021-01-07 17:44:29 +09:00
3f54f106dd
Merge "Remove mobile provision design out from connectivity service"
Chiachang Wang   authored and   Gerrit Code Review   commited 2021-01-07 06:47:26 +00:00
5e2637741b
Remove mobile provision design out from connectivity service
In order to support ConnectivityService mainline, module should
not use hidden APIs. The logic to get mobile provision is moved
to telephony surface since it's only used by telephony.
Hence, remove the design out from Connectivity.

Bug: 175177794
Test: atest FrameworksNetTests
Change-Id: Ic3082fc1c4d7ac998f4e4cff1351e6829d500924

Chiachang Wang   commited 2021-01-07 06:46:40 +00:00
0fd8e45b53
Merge "Replace withCleanCallingIdentity with [clear|restore]CallingIdentity"
Lucas Lin   authored and   Gerrit Code Review   commited 2021-01-07 04:32:54 +00:00
8971ccf93e
Merge "Migrate away from AsyncChannel in NetworkAgent"
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2021-01-06 14:10:21 +00:00
62cf62e0d9
[VCN02] Make LingerTimer takes request Id instead of NetworkRequest
Currently, LingerTimer takes a NetworkRequest for internal use.
However, this is unnecessary since only request Id is used.

Thus, this patch allows subsequent patches to remove the need
of a NetworkRequest when creating a LingerTimer. And the output
of lingered requests is reduced to id instead of printing
content of requests.

Test: atest FrameworksNetTests
Bug: 175180558
Change-Id: I9106d0804f1083942e1fcaca842f547c0aee1840

junyulai   commited 2021-01-06 17:26:12 +08:00
70afb0c48b
Replace withCleanCallingIdentity with [clear|restore]CallingIdentity
To prevent using @hide method - withCleanCallingIdentity() from
mainline module, use clearCallingIdentity() &
restoreCallingIdentity() instead.

Bug: 172183305
Test: FrameworksNetTests, CtsNetTestCasesLatestSdk
Change-Id: Iccd492741a0a5b1c2531fc5fc1378933b65ae038

lucaslin   commited 2020-12-30 11:54:55 +08:00
be80138c19
wifi: Add systemAPi:setSubscriberId in NetworkAgentConfig
The wifi (mainline module) need to set the subscriberId for specific
wifi network.

Bug: 176396812
Test: TreeHugger
Change-Id: Ie97d3dad81c87d41a360558e91c83278595ff475

lesl   commited 2020-12-28 18:15:52 +08:00
a37dda6024
Migrate away from AsyncChannel in NetworkAgent
Use two oneway binder interfaces instead.
The interfaces post messages to handlers as was implemented before, but
provide a more strictly defined interface, with less hops between
NetworkAgent, AsyncChannel, and ConnectivityService.

The actual public interface is the NetworkAgent @SystemApi: the binder
interface is an internal implementation detail.

Test: atest FrameworksNetTests CtsNetTestCasesLatestSdk
Bug: 173574274
Merged-In: Ie364ab50f416e7821e70f4539a881eea828e1256

Change-Id: Ie364ab50f416e7821e70f4539a881eea828e1256

Remi NGUYEN VAN   commited 2020-12-25 03:54:19 +00:00
77b0c1c72c
Merge "Split NetworkUtils and NetworkUtilsInternal"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2020-12-23 01:19:27 +00:00
a6a8451077
Merge "Move module utils to the module package."
Chalard Jean   authored and   Gerrit Code Review   commited 2020-12-21 05:35:09 +00:00
090cbf27ab
[IT03] Add replacement methods for network activity
Reference for NMS in ConnectivityManager should be removed for
incoming CS mainline. The API for listening network activity
should not go into NMS. As an alternative, the registry requests
should be sent to CS and handled by CS. Add necessary alternative
in IConnectivityManger first. The detail implementation will be
added in the follow up commits.

Bug: 170598012
Test: m
Change-Id: If4d24b937feb88a61f22073af2f671cf20298364

Chiachang Wang   commited 2020-12-21 03:48:54 +00:00
4068dcbab0