Commit Graph

5682 Commits

Author SHA1 Message Date
Paul Hu
ce1b5d00d9 Merge "Replace NetworkPolicyManagerInternal#isUidRestrictedOnMeteredNetworks()" 2021-01-22 14:18:47 +00:00
Chalard Jean
8e39c04b56 Merge "Add Qos Callback support" 2021-01-22 13:09:24 +00:00
paulhu
f0b4cd7fed Replace NetworkPolicyManagerInternal#isUidRestrictedOnMeteredNetworks()
Connectivity service is going to become a mainline module which
will not able to access hidden APIs. NetworkPolicyManagerInternal
is a internal serivce that CS can't be access after be a mainline
module. Thus, create NPMS#isUidRestrictedOnMeteredNetworks() and
NPM#isUidRestrictedOnMeteredNetworks() to replace
NPMI#isUidRestrictedOnMeteredNetworks().

Also correct the permission check in isUidNetworkingBlocked()
that needs to check OBSERVE_NETWORK_POLICY only.

Bug: 170598012
Test: atest FrameworksNetTests
Test: atest FrameworksCoreTests:NetworkPolicyManagerTest
Test: atest FrameworksServicesTests:NetworkPolicyManagerServiceTest
Test: atest CtsNetTestCases
Test: atest CtsHostsideNetworkTests
Change-Id: I5801a3a2076f3eb199a0226c38c85014b26c64e7
2021-01-22 16:14:28 +08:00
Remi NGUYEN VAN
649e3a28dd 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
2021-01-22 16:16:57 +09:00
Daniel Bright
2cc8ead3d6 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
2021-01-21 20:14:52 -08:00
Remi NGUYEN VAN
f7347c3b73 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
2021-01-21 22:36:54 +09:00
Chiachang Wang
92b94e1ec5 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
2021-01-21 08:40:12 +00:00
Paul Hu
e8bf3e902b Merge "Replace Context @hide API in MultinetworkPolicyTracker" 2021-01-21 07:53:19 +00:00
Remi NGUYEN VAN
24ea1e0377 Merge "Mark TestNetworkManager as module API" 2021-01-21 06:02:25 +00:00
Remi NGUYEN VAN
8700d3345b 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
2021-01-21 10:45:04 +09:00
paulhu
24e3388080 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
2021-01-21 01:19:09 +08:00
lifr
6e6149c471 Deprecated IP connectivity metrics system api
- In order to easily maintain the connectivity service.
Refactor the connectivity service by removing all legacy
metrics code & API.
- The commit will deprecate legacy metrics system api.
(The legacy metrics code will be removed in a separate commit.)
Therefore, those legacy metrics event may not be sent in
Android S and above.

Bug: 177043087
Test: atest ConnectivityServiceTest
      atest IpConnectivityMetricsTest
      atest ConnectivityServiceIntegrationTest
Change-Id: Ia057776869a7d38041b6eaf17904f6c54a7b4fca
2021-01-20 02:06:18 +00:00
Cody Kesting
48a1062811 Merge changes I61dd789f,I57c73264
* changes:
  Define add and remove for VCN policy listeners.
  Define VcnUnderlyingNetworkPolicy.
2021-01-19 19:37:53 +00:00
Junyu Lai
b380466d29 Merge "Revert "[VCN06] Support request background network"" 2021-01-19 10:24:47 +00:00
Junyu Lai
854241172b 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
2021-01-19 09:06:00 +00:00
Treehugger Robot
bd3110f654 Merge "Remove usage of NetCapability" 2021-01-19 05:16:00 +00:00
Junyu Lai
a18490bdde Merge "[VCN06] Support request background network" 2021-01-19 01:04:20 +00:00
junyulai
d4d56da595 [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
2021-01-18 16:32:08 +08:00
Treehugger Robot
36b467616c Merge "Remove usage of hidden .netId in IpConnectivityLog" 2021-01-18 06:36:02 +00:00
Chiachang Wang
1cad04fa9b Merge "Replace hidden ParcelFileDescriptor constructor usage" 2021-01-18 01:59:10 +00:00
Chiachang Wang
8636d9f5e5 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
2021-01-18 01:58:49 +00:00
Cody Kesting
80cde857e1 Define add and remove for VCN policy listeners.
Bug: 175729529
Test: atest FrameworksVcnTests
Change-Id: I61dd789fe4a4ebd1ca95866494d0e42e97c202cc
2021-01-15 09:21:59 -08:00
Cody Kesting
90f27fc842 Define VcnUnderlyingNetworkPolicy.
Bug: 175729529
Test: atest FrameworksVcnTests
Change-Id: I57c732640d6d21db1f4d68c69ff320918e7891c3
2021-01-15 07:55:18 -08:00
Remi NGUYEN VAN
d58bdcf4e5 Remove usage of NetCapability
The NetCapability annotation is internal to NetworkCapabilities. IntDef
annotations cannot be part of the API as per API guidelines, so the
NetCapability annotation cannot be used from outside of the connectivity
module, once it is built.

Bug: 174436414
Test: m
Change-Id: I1d6d87432d1e3af8a20169b18ceffa0c1130a836
2021-01-15 23:59:53 +09:00
Remi NGUYEN VAN
26a1726b88 Remove usage of hidden .netId in IpConnectivityLog
Use the Network#getNetId API instead.

IpConnectivityLog is planned to be outside of the connectivity module,
so it cannot use hidden symbols implemented in the module.

Bug: 174436414
Test: m
Change-Id: I947a32612c59b53f22fe1c38706de8919ca5043a
2021-01-15 23:59:20 +09:00
Cody Kesting
2ef4ac2c95 Define VcnTransportInfo.
This CL defines VcnTransportInfo - a TransportInfo to be used for
top-level VCN Networks registered with ConnectivityService.

Bug: 177261675
Test: atest FrameworksVcnTests
Change-Id: I66e9a0bf73c6e42eb5aa7fd39463fdfed483ecfa
2021-01-14 17:55:00 -08:00
Roshan Pius
d3ee5559ed Merge "NetworkCapabilities: Embed location senstive TransportInfo" 2021-01-14 15:38:15 +00:00
Aaron Huang
570985a03e Merge "Migrate Slog usage in MultinetworkPolicyTracker to Log" 2021-01-14 09:10:17 +00:00
Junyu Lai
539dbe61c5 Merge "[VCN05] Pass request type when requesting network" 2021-01-14 06:52:46 +00:00
Aaron Huang
1248c0376b 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
2021-01-14 09:53:38 +08:00
Aaron Huang
3b26172c84 Merge "Rename PacManager to PacProxyInstaller" 2021-01-14 01:52:24 +00:00
satayev
805f4d7c22 Merge "Revert "[VCN01] Add NOT_VCN_MANAGED capability"" 2021-01-13 17:40:03 +00:00
satayev
0e9334cb80 Revert "[VCN01] Add NOT_VCN_MANAGED capability"
This reverts commit 85e0ad7986.

Reason for revert: b/177411288 broken test

Bug: 177411288
Bug: 175662146
Change-Id: I02a25b83e62ab9a2ed22a98530d62b08de73f56e
2021-01-13 15:04:23 +00:00
Junyu Lai
357893095f Merge "Align coding style of line-wrapping in NetworkCapabilities" 2021-01-13 10:40:43 +00:00
Chiachang Wang
4bdcbf4608 Merge "[IT4.21] Update the label type of idle timer" 2021-01-13 09:10:43 +00:00
Aaron Huang
22eea532c5 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
2021-01-13 15:47:45 +08:00
junyulai
cf79261afc Align coding style of line-wrapping in NetworkCapabilities
Test: TH
Change-Id: Ic864524a60954f8dbcce265643c2cb3ac3aefca8
2021-01-13 07:45:18 +00:00
Junyu Lai
82ffaf2ac2 Merge "[VCN01] Add NOT_VCN_MANAGED capability" 2021-01-13 07:44:27 +00:00
Chiachang Wang
c095d60582 Merge "Replace hidden UserHandle.isApp() usage for mainline" 2021-01-13 07:34:49 +00:00
Chiachang Wang
3ce298dff1 [IT4.21] Update the label type of idle timer
The first parameter of adding idle timer is an unique identity
to communicate between ConnectivityService and netd. Netd will
notify the activity change using the identity, so it's fine to
replace the legacy type with transport type since we should
deprecate the usage of legacy type.

Bug: 170598012
Test: atest FrameworksNetTests
Change-Id: Ia00606539b86872cca9a92285bd940c8a720a033
2021-01-13 14:10:15 +08:00
Chiachang Wang
6548e1d84f Replace hidden UserHandle.isApp() usage for mainline
ConnectivityService is going to become a mainline module which
is not able to access hidden APIs. NetworkPolicyManager will be
part of connectivity framework sources which should also not
access hidden APIs. Thus, replace usage of UserHandle.isApp()
by public Process.isApplicationUid() instead.

Bug: 170598012
Test: m
Change-Id: I6eecc618d574352b924cb5f33f364e2dca9d730f
2021-01-13 03:23:58 +00:00
junyulai
85e0ad7986 [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
2021-01-13 11:05:40 +08:00
Roshan Pius
bf91915801 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
2021-01-13 02:25:49 +00:00
Hai Shalom
88baf235a9 Merge "Support for Venue URL and friendly name from Network agent" 2021-01-13 01:54:05 +00:00
Lorenzo Colitti
bbd9fb5c27 Merge changes I3eb82680,I9d6147d9
* changes:
  NetworkWatchlistServiceTests: update IIpConnectivityMetrics.
  Stop using IIpConnectivityMetrics in ConnectivityService.
2021-01-13 00:31:56 +00:00
Tomasz Wasilczyk
c353781098 Merge "Keep Vehicle internal network always up" 2021-01-12 22:40:50 +00:00
Tomasz Wasilczyk
ab315c597d Keep Vehicle internal network always up
Bug: 171801262
Test: Boot with and without overlay set and check ifconfig
Change-Id: I1fd332caf3e09924abcfec9c2c137363be7873e4
2021-01-12 10:33:38 -08:00
Patrick Rohr
1ab1849ab2 Merge changes I0731fa84,Id31a60ad
* changes:
  Add Restricted Mode handling to NetworkPolicyManager
  Refactor updating rules for all apps in NetworkPolicyManagerService
2021-01-12 17:40:24 +00:00
Lorenzo Colitti
682686bdff Stop using IIpConnectivityMetrics in ConnectivityService.
Currently, ConnectivityService calls the IpConnectivityMetrics
service class directly to log default network events. This is
incompatible with ConnectivityService being in a mainline module.
Replace direct access to IIpConnectivityMetrics with public
methods in IpConnectivityLog, which is @SystemApi class.

The new methods are not yet @SystemApi, but they can be made so
if desired. Alternatively, these metrics could be deleted.

Also remove the IpConectivityMetrics service from the
service-connectivity JAR, and go back to starting it from
SystemServer.java, which is what was happening a few hours ago
before aosp/1542626 was merged.

Test: builds, boots
Test: atest FrameworksNetTests
Test: "dumpsys connmetrics" shows events, including default network events
Change-Id: I9d6147d93590363a2f8f83f39f05c03d001b4851
2021-01-12 23:19:49 +09:00
Patrick Rohr
048bc5ea80 Add Restricted Mode handling to NetworkPolicyManager
Adds Restricted Mode functionality to NetworkPolicyManager. When this
mode is turned on (via setting), only apps with
android.permission.CONNECTIVITY_USE_RESTRICTED_NETWORKS will be able to
use the network. For all other apps, the network will be blocked by the
firewall. This is controlled by a new allowlist firewall chain
fw_restricted_mode.

As a first step, this implementation still requires a reboot after the
enabling / disabling the mode to take effect. I will provide the dynamic
configuration in the next CL.

Test: atest CtsHostsideNetworkTests && atest
NetworkPolicyManagerServiceTest
Bug: 170322816
Bug: 157505406
Bug: 170322455
Bug: 175281879

Exempt-From-Owner-Approval: Change already merged on internal gerrit.
Change-Id: I0731fa842c69683953baaf9ec3a9a03454f4c607
Merged-In: I0731fa842c69683953baaf9ec3a9a03454f4c607
2021-01-12 11:59:17 +00:00