Commit Graph

5627 Commits

Author SHA1 Message Date
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
Benedict Wong
20bfe66a02 Merge changes I3b769562,I63203188,Ia9396d66,Ifec34fad
* changes:
  Pull VcnNetworkProvider out into a separate class
  Verify carrier privileges for VCN-providing packages
  Add TelephonySubscriptionTracker to VcnMgmtSvc
  Add basic VcnMgmtSvc --> Vcn signals (startup, teardown, NetworkReq)
2021-01-08 22:29:40 +00:00
Junyu Lai
2960af3978 Revert "wifi: Add systemAPi:setSubscriberId in NetworkAgentConfig"
This reverts commit 7521c2277a.

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

Change-Id: I2e8840a797df9d1594f2b8b576bcd45beb184fca
2021-01-08 19:22:28 +08:00
Treehugger Robot
5b322f10be Merge "Pivot network statistics to use DataInput/Output." 2021-01-08 10:33:16 +00:00
Benedict Wong
9cb5807845 Verify carrier privileges for VCN-providing packages
This change adds and verifies packages in the VcnManagmentService,
ensuring that carrier privilege gain/loss correctly starts/tears down
VCN instances.

Bug: 163431877
Test: atest FrameworksNetTests
Change-Id: I63203188c57fdde1cfc58aaf1108aa3e70eb4a50
2021-01-07 17:13:37 -08:00
Les Lee
6ae2535ec6 Merge "wifi: Add systemAPi:setSubscriberId in NetworkAgentConfig" 2021-01-08 00:54:51 +00:00
Lorenzo Colitti
282ed251ce 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
2021-01-07 17:44:29 +09:00
Chiachang Wang
518d9d8f27 Merge "Remove mobile provision design out from connectivity service" 2021-01-07 06:47:26 +00:00
Chiachang Wang
454497b7df 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
2021-01-07 06:46:40 +00:00
Lucas Lin
c7906266c5 Merge "Replace withCleanCallingIdentity with [clear|restore]CallingIdentity" 2021-01-07 04:32:54 +00:00
Jeff Sharkey
6b773549e3 Pivot network statistics to use DataInput/Output.
Using these generalized interfaces is more flexible, since it enables
us to pivot the implementation being used internally.  In particular,
an upcoming CL will pivot them to use a more efficient alternative.

This is a no-op refactoring.

Bug: 176777285
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: Ibd4717174cf1f136e9d5d80172ecb6e493265306
2021-01-06 18:48:12 -07:00
Lorenzo Colitti
91348d9f22 Merge "Migrate away from AsyncChannel in NetworkAgent" 2021-01-06 14:10:21 +00:00
lucaslin
0d01b3b1eb 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
2020-12-30 11:54:55 +08:00
Paul Hu
6bc7032b85 Merge "Add DnsResolverServiceManager" 2020-12-29 02:14:59 +00:00
lesl
7521c2277a 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
2020-12-28 18:15:52 +08:00
Remi NGUYEN VAN
a9b2fddb51 Merge "Register ethernet listeners on specific Executors" 2020-12-28 07:12:45 +00:00
Chiachang Wang
dcb4051101 Merge "[IT4.2] Update argument type of interfaceClassDataActivityChanged" 2020-12-28 01:05:28 +00:00
Remi NGUYEN VAN
92f546d4bd 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
2020-12-25 03:54:19 +00:00
Serik Beketayev
4abaecefc2 [Mainline] Migrate ProxyInfo
Bug: 173455434
Test: atest FrameworksNetTests
Change-Id: I924aed710b62a0c91b888a9e04ac2c90cdfd88d0
2020-12-23 22:15:51 -08:00
Aaron Huang
120dfbbec5 Have NetworkPolicyManagerService create MultipathPolicyTracker
To make connectivity service mainline, this patch makes
MultipathPolicyTracker as a submodule of NetworkPolicyManagerService
to remove the dependencies of ConnectivityService.

Bug: 175015282
Test: FrameworksNetTests
Change-Id: I82a7c62069ffd0683deb2f5ce2f99de120a2a16f
2020-12-23 23:17:15 +08:00
Chiachang Wang
4dd4e08c4e [IT4.2] Update argument type of interfaceClassDataActivityChanged
The argument type of interfaceClassDataActivityChanged takes a
string for the network type. It requires both the receivers and
NMS to do type transformation. The transformation is a redundant
work. Update it to take integer directly and rename to
understandable naming.

Bug: 170598012
Test: atest FrameworksNetTests
Change-Id: Ibe9fa7a1b71af2dab916b5d615742e77e4174c39
2020-12-23 17:34:08 +08:00
Chiachang Wang
baef452e38 Merge "[IT04] Add uid as parameter of interfaceClassDataActivityChanged" 2020-12-23 05:20:33 +00:00
Remi NGUYEN VAN
3ed4fd3a89 Merge "Split NetworkUtils and NetworkUtilsInternal" 2020-12-23 01:19:27 +00:00
paulhu
b6fcddfd5d Add DnsResolverServiceManager
Add DnsResolverServiceManager to obtain android.net.IDnsResolver
IBinder for incoming connectivity service mainline.

Bug: 170598012
Test: atest FrameworksNetTests
Change-Id: Ibd7a678ceaaa550ff3d8eff1d0c4d3a5073b5527
2020-12-22 21:31:39 +08:00
Benedict Wong
ba3f1179a8 Merge "Add additional javadoc for VcnManager" 2020-12-22 08:11:02 +00:00
Chiachang Wang
9c133bc4e9 [IT04] Add uid as parameter of interfaceClassDataActivityChanged
Add uid into interfaceClassDataActivityChanged in
INetworkManagementEventObserver. This helps the listeners to use
BaseNetworkObserver to listen for target evnets instead of using
whole INetdUnsolicitedEventListener with no-op in other event
that listeners do not care about.

Bug: 170598012
Test: m ; atest FrameworksNetTests
Change-Id: I2a42a522c2ff9b1e0be88261a8574bb7f5292fa6
2020-12-22 08:39:22 +08:00
Benedict Wong
c0e2e1c9bd Merge changes Ifabf5e2b,I2e632532
* changes:
  Add persistence for VcnConfig objects by Subscription Group
  Implement basic VcnConfig and VcnGatewayConnectionConfig
2020-12-21 07:10:36 +00:00
Chalard Jean
eeb7c450aa Merge "Move module utils to the module package." 2020-12-21 05:35:09 +00:00
Chiachang Wang
6703edcfed [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
2020-12-21 03:48:54 +00:00
Benedict Wong
7fb0db69b4 Add additional javadoc for VcnManager
This change adds additional detail for the VCN, describing feature set,
use cases and fail-safe modes.

Bug: 163431877
Test: Compiles, Boots (Comment-only change)
Change-Id: I1f82267c20dbbf5875ae27117debdb58f7b96e57
2020-12-18 09:08:54 +00:00
Benedict Wong
ab1b484ac7 Add persistence for VcnConfig objects by Subscription Group
This commit adds the ability for the VcnManagementService to track/store
VCN profiles by subscription groups, and saving/loading to/from disk.

Bug: 163611304
Test: New tests added, passing
Change-Id: Ifabf5e2be090d529cd29e2c68d55ece4858b2aad
2020-12-17 17:17:13 -08:00
Benedict Wong
264973663c Implement basic VcnConfig and VcnGatewayConnectionConfig
This change adds some of the basic fields in VcnConfig and
VcnGatewayConnectionConfig, plus adds a persistability layer to ensure
all VcnConfig(s) are disk-stable.

Bug: 163602123
Bug: 163594033
Test: New tests added, passing
Change-Id: I2e632532809e7768b284be376f2b0a77f634fef5
2020-12-16 17:51:58 -08:00
Chalard Jean
95b575f468 Move module utils to the module package.
Test: FrameworksWifiTest FrameworksNetTest
Change-Id: If5d1e4a58fb2d6d9544e6d01995dabe445cf1f25
Merged-In: I067eeecd458c34b7f2fbfa439072682661ac750c
2020-12-16 11:44:22 +09:00
Sarah Chin
7f21ec08f7 Move phone ID to extra for action provision
Previously, the phone ID was appended to the broadcast in DCT and sent
to ConnectivityManager. Instead of sending both as an action, send the
phone ID as an extra instead to make the action a protected broadcast.

Test: manually verify a SecurityException when action provision is sent
Test: atest DcTrackerTest
Bug: 172459128
Change-Id: Ic4129def86949d7191d15056852718dadbd72fba
Merged-In: Ic4129def86949d7191d15056852718dadbd72fba
2020-12-15 10:55:22 -08:00
Remi NGUYEN VAN
eada640d5d Merge changes from topic "tcp_keepalive_fix"
* changes:
  Use API TcpKeepalivePacketData in ClientModeImpl
  Add TcpKeepalivePacketData to SystemApi
2020-12-15 09:02:55 +00:00
Remi NGUYEN VAN
32a5b51fe2 Register ethernet listeners on specific Executors
Have users of EthernetManager#addListener specify an Executor instead of
running callbacks on ConnectivityThread.
For existing clients, run callbacks on the common BackgroundThread.

This change in behavior is fine because addListener is not an API, the
threading model in Q was to run callbacks on the looper of the thread
that first created EthernetManager (so there is already no guarantee on
which thread is used), and the only users are in Settings.

ConnectivityThread is moving to a connectivity-specific JAR, so it
should not be used by external classes.

Bug: 174436414
Test: Ethernet client / tethering working
      atest TetheringIntegrationTests
Change-Id: Ic9a959f89915329f79eeeaa0a210ad50811d1291
2020-12-15 17:57:32 +09:00
Chiachang Wang
9924f6ac8f Merge "Remove hidden deprecated getActiveNetworkQuotaInfo" 2020-12-15 07:02:54 +00:00
Chiachang Wang
8fd2f6d2aa Remove hidden deprecated getActiveNetworkQuotaInfo
getActiveNetworkQuotaInfo has never been in API surface since it
was introduced. It became essentially functionless since android O,
so there should be no usage dependency upon the hidden method,
In order to support ConnectivityService mainline, remove the
useless function to prevent necessary dependency.

Bug: 172183305
Test: atest FrameworksNetTests
Change-Id: Ia685b3260256d465ef614b2f577d13344074c787
2020-12-15 06:45:50 +00:00
Remi NGUYEN VAN
103ec4aa8d 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
Paul Hu
f24f42ad0f Merge "Expose TcpRepairWindow as module-lib API" 2020-12-11 05:37:10 +00:00
Chalard Jean
362fc1ca1f Merge changes from topic "remove_legacy_NA"
* changes:
  Remove support for legacy network agents
  Remove deprecated constructors for NetworkAgent
  Migrate NetworkAgentWrapper to the new NA API
  Cleanup TestNetworkService
2020-12-11 02:32:57 +00:00
Jeff Sharkey
c9dc68f063 Merge "Update OWNERS info for NetworkPolicy related files." 2020-12-10 14:33:07 +00:00
Sudheer Shanka
7012c9e873 Update OWNERS info for NetworkPolicy related files.
Test: n/a
Change-Id: I8abcde37bd76bc1078119ca10232a46130668306
2020-12-10 08:19:35 +00:00
Lorenzo Colitti
435d580374 Merge changes I6eb6d92b,I638e29fd,I2348b7a3
* changes:
  Add a convenience method to update a network's capabilities.
  Disallow NetworkAgents from changing the owner UID.
  Observe mOwnerUID in NetworkCapabilities#equals.
2020-12-10 08:11:52 +00:00
Lorenzo Colitti
039ed698f1 Observe mOwnerUID in NetworkCapabilities#equals.
Currently, NetworkCapabilities's equals and hashCode methods
ignore mOwnerUID. This is confusing because it is inconsistent
with pretty much every other member of this class.

Bug: 175188445
Test: atest CtsNetTestCases:NetworkAgentTest \
            CtsNetTestCases:Ikev2VpnTest \
	    CtsNetTestCases:VpnServiceTest HostsideVpnTests \
	    CtsNetTestCases:android.net.cts.ConnectivityDiagnosticsManagerTest \
	    ConnectivityServiceTest com.android.server.connectivity.VpnTest
Change-Id: I2348b7a35f32a931687f2d3c2fa57620a12fe06f
2020-12-09 19:33:32 +09:00
paulhu
81bbd3c1db Expose TcpRepairWindow as module-lib API
Connectivity service is going to become a mainline module which
will not be able to access hidden APIs. TcpKeepaliveController
is a part of CS mainline module, it uses TcpRepairWindow to
store tcp repair window info. Thus, expose TcpRepairWindow as
module-lib API to support the usage.

Bug: 172183305
Test: atest FrameworksNetTests
Change-Id: I1b6f5ae698f4b6e030a0f776aeafc774fa9f1437
2020-12-09 08:25:13 +00:00
Chalard Jean
b27cdc85e3 Remove support for legacy network agents
Test: FrameworksNetTests NetworkStackTests
Bug: 167544279
Change-Id: Ia950e16d991cd08d4b609d71aad61a4a4f7fda39
2020-12-08 19:43:11 +09:00
Chalard Jean
4290037d5e Remove deprecated constructors for NetworkAgent
Finally.

Now that mLegacy is always false, removing the support
for legacy agents, a follow-up change will remove
the member and all the associated code.

Test: FrameworksNetTests NetworkStackTests
Bug: 167544279
Change-Id: I6e2c27facdd3ecc232a0aa32bf57c33cb06f118e
2020-12-08 19:43:11 +09:00
Remi NGUYEN VAN
684a7409e6 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
Serik Beketayev
9817226d99 [Mainline Migration] Migrate NetworkUtils
Migrating makeStrings(), numericToInetAddress() APIs

Bug: 173089079
Test: atest FrameworksNetTests
Change-Id: Ie914fd41bc3ce16d07f5d2768b89ce805b9245a9
2020-12-06 22:33:04 -08:00