Commit Graph

438 Commits

Author SHA1 Message Date
junyulai
05738ae9d3 [VCN20] Change requestBackgroundNetwork argument order
Test: atest FrameworksNetTests FrameworksVcnTests
Fix: 185215095
Merged-In: Id281678fe85ce0894b0e92e11c0283d4d1b4ecdb
Change-Id: Id281678fe85ce0894b0e92e11c0283d4d1b4ecdb
  (cherry-picked from ag/14198667)
2021-04-16 00:16:21 +08:00
lifr
dbee04c122 Add session ID to VpnTransportInfo
- This will be visible only to apps with the NETWORK_SETTINGS
  permissions (signature), and will be redacted for all other callers.
- This string is expected to be the same as set by
  VpnService#setSession, and in general, VpnConfig.session. But it
  will be a general API that Vpn.java can call when setting the
  VpnTransportInfo.
- This string cannot be updated once the VPN NetworkAgent is connected.

Bug: 171872481
Test: atest ConnectivityServiceTest
      atest VpnTransportInfoTest
      atest android.net.cts.NetworkAgentTest
Change-Id: I8d09e25b83f7ee8be21ec9c9bd3c72a251f1370d
Merged-In: I8d09e25b83f7ee8be21ec9c9bd3c72a251f1370d
           (cherry-picked from ag/14011912)
2021-04-01 15:46:31 +08:00
Lorenzo Colitti
79c6f228a6 Add onBlockedStatusChanged(Network, int) to NetworkCallback.
This is similar to onBlockedStatusChanged(Network, boolean) but
it allows the callback holder to know the exact reason why
networking was blocked. It is useful to privileged system
components such as JobScheduler that are able to ignore some
blocked reasons but not others.

Also add a new BLOCKED_REASON_LOCKDOWN_VPN that is used when
networking is blocked because an always-on VPN is in
lockdown mode.

Also move BLOCKED_METERED_REASON_MASK to ConnectivityManager.
This is necessary because ConnectivityService must ensure that
the blocked status callbacks are correctly sent when meteredness
changes (e.g., a UID that is blocked on metered networks will
become unblocked on a network that becomes unmetered). In order
to do this it needs to know which reasons apply only on metered
networks.

Bug: 165835257
Test: unit tests in subsequent CLs in the stack
Change-Id: I647db4f5a01280be220288e73ffa85c15bec9370
2021-03-26 02:37:19 +09:00
Lorenzo Colitti
2a49c5d456 Support calling registerDefaultNetworkCallback for another UID.
This is to be used by privileged components (e.g., JobScheduler)
to request callbacks about the state of other UIDs on the system.

Bug: 165835257
Test: new unit test coverage
Change-Id: I29f155710394e58c14fcef488db6271d8d83033a
2021-03-22 17:52:20 +09:00
Remi NGUYEN VAN
0d4c78d80d Migrate framework-connectivity internal resources
Use ServiceConnectivityResources instead.
Start by creating resources in the ServiceConnectivityResources package
to match the internal configuration, and common overlays.

Bug: 182125649
Test: device boots, has connectivity
Change-Id: I77a3efca2cd644f9828db1ed5d3cae8070fb8363
Merged-In: I77a3efca2cd644f9828db1ed5d3cae8070fb8363
2021-03-20 22:35:16 +09:00
Lorenzo Colitti
4bd4ad4597 Merge "Add a VpnManager.TYPE_VPN_OEM." 2021-03-18 13:12:08 +00:00
Lorenzo Colitti
caa5a17f3d Add a VpnManager.TYPE_VPN_OEM.
This needed for OEMs that have VPN types not supported by AOSP.

Bug: 171872481
Test: new test coverage in VpnTransportInfoTest
Change-Id: Ic7529bef7f12d2c74a3be5b1a4a2d54fb0d0bfac
2021-03-18 05:54:53 +00:00
paulhu
56e09df8db Add more connectivity module settings
Add more connectivity module settings and update all references
to ConnectivitySettingsManager.

Bug: 182538166
Test: atest FrameworksNetTests
Change-Id: Ie96fbd0996ed3acb37099b6270bf3d4c2e558e9a
2021-03-18 11:58:29 +08:00
Roshan Pius
951c003ef4 ConnectivityManager: Provide API's to include location sensitive info
Existing NetworkCallback users will get NetworkCapabilities with
location sensitive data removed (except for ownerUid which will be
added for existing apps for backwards compatibility). Apps
have to opt-in to receive location sensitive data.

Note: This was chosen because WifiInfo is the only TransportInfo tha
has location sensitive info & that was added only in Android 12. If we
choose to default to true, all existings apps retrieving
NetworkCapabilities for wifi networks will be blamed for location access
unnecessarily.

Changes:
i) Add a flag in NetworkCallback creation to retrieve
NetworkCapabilities with location sensitive info in their callback.
(More flags are being planned for NetworkCallback for throttling
callback frequency, etc)
ii) For NetworkCapabilities.getOwnerUid(), we will continue to send the
data for apps targeting older SDK (since this is an existing field and
the new flag defaults location sensitive data to off).

Bug: 156867433
Test: atest android.net
Test: atest com.android.server
Change-Id: If70b5ea6f5c8885f0c353c8df08a826d55fe7f7a
2021-03-11 18:27:18 -08:00
junyulai
962bdb8677 [VCN11] Make requestBackgroundNetwork requires handler
Test: atest FrameworksNetTests android.net.cts.ConnectivityManagerTest
Bug: 175662146
Change-Id: Iac9487e8de8bfdd87fc7a0153b228ae2a7ba4e19
2021-03-11 21:05:27 +08:00
Zoey Chen
1b4ea1877b [Telephony] Use TelephonyCallback instead of PhoneStateListener part1
Since the redesign of PhoneStateListener, use TelephonyCallback to get the callback of EVENT_*

Bug: 167684594
Test: make
Change-Id: Ia3b777b12142b104b5798804f50b34748f9bf28c
Merged-In: Ia3b777b12142b104b5798804f50b34748f9bf28c
2021-03-08 20:25:00 +08:00
Yan Yan
5bab9c0448 Merge "Support new IpSecAlgorithm AUTH_AES_CMAC" 2021-03-02 18:24:27 +00:00
junyulai
14133c117d [FUI09] Expose NetworkStateSnapshot as system API
This is needed by NetworkStatsService and
NetworkPolicyManagerService to utilize the snapshots of
information of networks that grabbed from ConnectivityService.

Test: atest FrameworksNetTests NetworkPolicyManagerServiceTest
Bug: 174123988
Change-Id: I7e974ef7b23ba9ba6ee775eed9899b0c0e2eca55
2021-03-02 23:09:16 +08:00
junyulai
de41fc2022 [FUI17] Migrate NetworkStatsService to use NetworkStateSnapshot
This change migrates NetworkStatsService and related code to use
NetworkStateSnapshot which is used for replacing the NetworkState.

This patch also changes some formating which is suggested by
the linter.

Test: FrameworksNetTests NetworkPolicyManagerServiceTest
Bug: 174123988
Change-Id: I547da8f411cb45bdadc376ac3cadf3f3c55bb282
2021-03-02 20:08:53 +08:00
Junyu Lai
ff35256ebd Merge "Fix copyright license of VpnTransportInfo" 2021-02-26 03:38:59 +00:00
Chris Weir
2a6448ce32 Merge "Update tests for PANS network usage metrics" 2021-02-25 21:37:42 +00:00
Yan Yan
6ca69e5f31 Support new IpSecAlgorithm AUTH_AES_CMAC
Bug: 161716062
Test: IpSecAlgorithmTest, verified with CTS
Change-Id: Ideaf4225bd851fad8c8072505c6ad99d85ba616e
2021-02-25 10:35:10 -08:00
Paul Hu
5f72702134 Merge "Use alternative PhoneStateListener formal API" 2021-02-25 12:14:53 +00:00
junyulai
c8d3b9308f Fix copyright license of VpnTransportInfo
Test: TH
Bug: None
Change-Id: Id1fe2c62a0fd60b9833d8b00d2fa2ddc2f031004
2021-02-25 10:31:56 +08:00
Chris Weir
13c3b49fe9 Update tests for PANS network usage metrics
Update existing tests to use new NetworkTemplate/NetworkIdentity
constructors, and add additional tests for new PANS metrics features.

Bug: 175793874
Bug: 174485293
Test: Run the tests in this CL with atest

Change-Id: I6f50993397d886a266874da0047c02022a69f62e
2021-02-23 22:16:19 -08:00
paulhu
d42261fea3 Use alternative PhoneStateListener formal API
MultinetworkPolicyTracker is part of Connectivity mainline module
which cannot call @hide API to register PhoneStateListener. Thus,
replace it to formal API.

Bug: 171183530
Test: atest FrameworksNetTests
Change-Id: Ib02790623e82726aaada33f559226020d1e0019b
2021-02-22 14:31:58 +08:00
Junyu Lai
9d8d6ff5c3 Merge "[FUI15] Remove networkId in NetworkState" 2021-02-20 14:00:19 +00:00
Lorenzo Colitti
cd67529417 Move VPN code from ConnectivityService to VpnManagerService.
ConnectivityService itself does not depend on mVpns or the Vpn
class any more. Most of this CL is simply moving code from one
class to another:

- Move the AIDL calls from IConnectivityManager to IVpnManager.
- Move the implementation from ConnectivityService to
  the new VpnManagerService.
- Move the APIs from ConnectivityManager to VpnManager, but
  temporarily maintain some shims in ConnectivityManager for the
  moved calls so that existing callers do not have to be modified
  in this CL.
- Update VpnService to call IVpnManager instead of
  IConnectivityManager.
- Move the code that registers the VpnManager service from
  ConnectivityFrameworkInitializer to SystemServiceRegistry.

Bug: 173331190
Test: atest HostsideVpnTests FrameworksNetTests CtsNetTestCases
Change-Id: I4911e2144df721a94fa00da9edf0dc372a7091c2
2021-02-12 01:12:24 +09:00
Lorenzo Colitti
9f38060e30 Minor fixes to VpnTransportInfo.
This CL addesses comments on aosp/1570921.

Bug: 173331190
Test: new test coverage
Change-Id: Ie8e1bd63bb818a03f4b17402e1b365577ca034a2
2021-02-11 23:28:00 +09:00
Lorenzo Colitti
5597c03563 Merge changes from topics "vpnmove-getconnectionowneruid", "vpnmove-systemdefaultcallback", "vpnmove-vpntransportinfo"
* changes:
  Stop using mVpns in getConnectionOwnerUid.
  Add a VpnTransportInfo object.
  Add a registerSystemDefaultNetworkCallback method.
2021-02-10 06:38:41 +00:00
Lorenzo Colitti
31a31193d2 Add a VpnTransportInfo object.
This currently stores the VPN type and a session name, but can be
extended in the future.

Bug: 173331190
Test: added coverage in VpnTest
Test: added coverage in ConnectivityServiceTest
Test: added coverage in NetworkAgentTest
Change-Id: I450858a9fa332c8d896dbdb4c14337d5ec23677f
2021-02-10 02:52:16 +09:00
Lorenzo Colitti
76b639e1bc Add a registerSystemDefaultNetworkCallback method.
This method allows internal components to track the system
default network. This differs from registerDefaultNetworkCallback
because that method sends callbacks for the default network for
the UID that called it. This may not be the system default
network, for example, when a VPN is up and applies to the UID.

Bug: 173331190
Test: new unit tests in ConnectivityServiceTest
Test: new unit tests in ConnectivityManagerTest
Test: new CTS tests in ConnectivityServiceTest
Test: new CTS tests in HostsideVpnTests in other CL in this topic
Change-Id: Id02748a2183f71b71ff2a53a580466b9dcecaa93
2021-02-09 20:58:28 +09:00
Junyu Lai
bb44ed9da9 Merge changes from topic "removeNI"
* changes:
  [FUI07] Stop making NetworkState with NetworkInfo from external callers
  [FUI06] Stop using NetworkInfo in NetworkState from external callers
2021-02-09 03:37:59 +00:00
Roshan Pius
aa24fdeb5d ConnectivityService: Plumb attribution tag for location permission checks
Not currently setting the atttribution tag for location
permission checks. Plumb the attribution tag for all location permision
checks (so that location access is correctly attributed to individual
components within an app)

Bug: 162602799
Test: atest android.net
Test: atest com.android.server
Change-Id: Iee95f05204f51a4f8cb1f36acfb60e8cdeb156f4
2021-02-08 08:13:48 -08:00
junyulai
7afe1ddb29 [FUI15] Remove networkId in NetworkState
Follow-up from aosp/1542748. networkId is unused and it is
safe to remove them now.

Test: atest FrameworksNetTests NetworkPolicyManagerServiceTest
Bug: 174123988
Change-Id: Ifc9cdad79a3d772035c73116de3f64dd6237b747
2021-02-08 22:16:08 +08:00
junyulai
23e22618cf [FUI07] Stop making NetworkState with NetworkInfo from external callers
Follow-up from previous patch. This change stop accessing the
constructor that needs NetworkInfo to create NetworkState, which
is no longer accessible after ConnectivityService become
mainline module. Instead, pass a legacy network type which is
dedicated for the need of the type.

Test: atest FrameworksNetTests NetworkPolicyManagerServiceTest
Bug: 174123988
Change-Id: I24157bc33e5a5819eccd6a3111d2049f531c1d43
2021-02-08 21:58:02 +08:00
junyulai
d49aab92c9 [FUI06] Stop using NetworkInfo in NetworkState from external callers
This is achieved by:
  1. Use legacy network type inside NetworkState to replace the
     needs of referencing NetworkInfo.getType().
  2. Let getAllNetworkState only return networks with isConnected()
     equals true. This allows callers such as NPMS or NSS does not
     have to reference to NetworkInfo.isConnected().

Test: atest FrameworksNetTests NetworkPolicyManagerServiceTest
Bug: 174123988
Change-Id: I1c4eb08d18ca973eb8f41d06258872eabc0006b8
2021-02-08 21:40:49 +08:00
Treehugger Robot
2685347482 Merge "Update frameworks to use unbundled version of BouncyCastle." 2021-02-02 14:37:05 +00:00
Junyu Lai
a62493f45b [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
Daulet Zhanguzin
9a357a92a2 Update frameworks to use unbundled version of BouncyCastle.
Previously BouncyCastle methods were exposed as libcore APIs (@CorePlatformApi), which no longer possible when ART is updatable module (and can't guarantee BouncyCastle API stability)

Bug: 154796679
Test: Treehugger

Change-Id: I908681841a6766de88761767c77c4e2d4b5f56d5
2021-01-28 07:51:22 +00:00
Treehugger Robot
96e49f0e2b 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
junyulai
e0ee198758 [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
e8b27cc9d8 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
Junyu Lai
dfb7780384 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
junyulai
75daea17c8 [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
junyulai
ad0107998f [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
2021-01-12 19:55:00 +08:00
Serik Beketayev
a9dc6770b2 [Mainline] Migrate ProxyInfo
Bug: 173455434
Test: atest FrameworksNetTests
Change-Id: I924aed710b62a0c91b888a9e04ac2c90cdfd88d0
2020-12-23 22:15:51 -08:00
Remi NGUYEN VAN
a6a8451077 Merge "Split NetworkUtils and NetworkUtilsInternal" 2020-12-23 01:19:27 +00:00
Chalard Jean
79162540bf Move module utils to the module package.
Test: FrameworksWifiTest FrameworksNetTest
Change-Id: If5d1e4a58fb2d6d9544e6d01995dabe445cf1f25
Merged-In: I067eeecd458c34b7f2fbfa439072682661ac750c
2020-12-16 11:44:22 +09:00
Remi NGUYEN VAN
0956b8a3de Use API TcpKeepalivePacketData in ClientModeImpl
Instead of statically linking against and jarjaring
TcpKeepalivePacketData, use the new android.net.TcpKeepalivePacketData
API for S. On R, build the KeepalivePacketDataParcelable from the base
KeepalivePacketData class.

The current ClientModeImpl code that uses a statically linked
TcpKeepalivePacketData is actually broken, as since R the system_server
has been sending a @hide android.net.TcpKeepalivePacketData, and
ClientModeImpl was testing it against com.android.wifi.x.android.net.*.
To fix this on R, this change rebuilds a
TcpKeepalivePacketDataParcelable class from the packet data included in
the base KeepalivePacketData class.

Bug: 172789687
Test: atest ConnectivityManagerTest#testCreateTcpKeepalive
      See associated test change
Change-Id: Ia32b4444dbf90306b2cfd37ec13d4ba4e90cd1e8
2020-12-14 18:43:53 +09:00
Remi NGUYEN VAN
5e6b51b895 Add TcpKeepalivePacketData to SystemApi
This is consistent with NattKeepalivePacketData, which is also a
subclass of KeepalivePacketData.

TcpKeepalivePacketData is already used by the wifi module, but
statically linked.

Bug: 172789687
Test: m
Change-Id: I6aee1ae205987521bea4a3838bbece279ffa0e37
2020-12-14 18:43:44 +09:00
Remi NGUYEN VAN
b293c47ac8 Split NetworkUtils and NetworkUtilsInternal
NetworkUtils is planned to move to a dedicated JAR for connectivity
classes, while NetworkUtilsInternal would stay in the
frameworks-minus-apex JAR, in the com.android.internal.net package.

Bug: 171540887
Test: m, boots, wifi working
      atest FrameworksNetTests
Change-Id: I3d38d72ad23a4bf84af823c7baeb6fed25c0665f
2020-12-07 19:41:49 +09:00
Lorenzo Colitti
88987d44f3 Add a test for TcpKeepalivePacketDataParcelable.toString().
Test: test-only change
Change-Id: I4c15f311e5bb328e8c74602e67d74baec3f89743
2020-11-18 10:53:44 +00:00
Xiao Ma
7167773060 Merge changes from topic "revert-1353490-revert-1323251-ipv6_prov_loss_quirk_parcelable-DVBHZDYMHA-MDHWFKJABZ"
* changes:
  Add jarjar rule for IPv6ProvisioningLossQuirk.
  Revert "Revert "Test IPv6ProvisioningLossParcelable in the NetworkAttributes"""
2020-10-29 05:39:16 +00:00
Xiao Ma
ed0fdd959d Add jarjar rule for IPv6ProvisioningLossQuirk.
A new stable parcelable IPv6ProvisioningLossQuirk added in network
stack module, which is used to record the network quirk info which
causes IPv6 provisioning loss, e.g. the router lifetime in RA is 0
and the default route will be removed from LinkProperties.

Previously this change breaks CtsStrictJavaPackagesTestCases due to
a jarjar rule is missed. Also rename the package name based on the
revert change.

Also include slight stable AIDL package and variable rename.

Bug: 157534516
Test: atest CtsStrictJavaPackagesTestCases FrameworksNetTests
Change-Id: Ic2f6b75beefb574f7e2fb4c157667e7734eccd05
2020-10-27 08:04:29 +00:00